Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Elegant Way of Inserting Text at the Start of the File

by Util (Priest)
on Nov 19, 2008 at 01:20 UTC ( [id://724442]=note: print w/replies, xml ) Need Help??


in reply to Elegant Way of Inserting Text at the Start of the File

Either of these:

perl -i -wpe 'print "new text\n" if $. == 1;' file
perl -MTie::File -we 'tie @L, "Tie::File", "file" or die; unshift @L, +"new text";'
See perlrun for the meanings of the command-line flags.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-28 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found