in reply to begining of a file

Please refer to the Perl FAQ: How do I change one line in a file/delete a line in a file/insert a line in the middle of a file/append to the beginning of a file?

Replies are listed 'Best First'.
Re: begining of a file
by s0ttle (Scribe) on Aug 21, 2001 at 20:46 UTC
    open (FILE,"<file") || die "Could not open file : $!\n"; @contents = <FILE>; $head = shift(@contents); close(FILE); $new_entry = 'Welcome to www.perlmonks.org'; open (FILE, ">file") || die "Could not open file : $!\n"; unshift (@contents,$head,$new_entry); print FILE "@contents\n"; close(FILE);
    Can be simplified, but it works....