CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Help me please

 



Cold-ice.com
Deleted

Jan 8, 2000, 9:49 AM

Post #1 of 2 (2045 views)
Help me please Can't Post

Hi there,
i'm just a beginning perl programmer and need some help.

how can I write the first 4 lines of a file to an other file.

For example:
The first 4 lines of contest.txt need to be written into the file contest2.txt

Thanks


Borderline
Deleted

Jan 8, 2000, 9:55 AM

Post #2 of 2 (2045 views)
Re: Help me please [In reply to] Can't Post

Hi,

open FILE1, "contest.txt"
or die "Could not open contest.txt: $!";
open FILE2, ">contest2.txt"
or die "Could not open contest2.txt: $!";
while (<FILE1> ) {
print FILE2;
last if $. == 4;
}
close FILE1;
close FILE2;

Hope this helps
Scott

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives