Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: insert into beginning of file

by fsn (Friar)
on Jul 22, 2002 at 15:07 UTC ( [id://184089]=note: print w/replies, xml ) Need Help??


in reply to insert into beginning of file

Tie::File is of course the way to do it. The old, hardcore, quickhack, low memory, no extra module, the-way-they-used-to-do-it-in-the-80's way is:

#!/usr/bin/perl open INFILE, "<infile"; open OUTFILE, ">tmpfile"; # Create your temporary names with care, +or die a painful race-condition death. print OUTFILE qq!Here you print the new stuff. ... !; while (<INFILE>) { print OUTFILE $_; } close INFILE; close OUTFILE;

and then rename the tempfile.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://184089]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-20 04:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found