Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

RE: Re: Writing to files

by btrott (Parson)
on Apr 10, 2000 at 20:42 UTC ( #7245=note: print w/replies, xml ) Need Help??


in reply to Re: Writing to files
in thread Writing to files

Unfortunately, this doesn't work, because the BEGIN occurs before STDOUT is redirected to the output file (the file you're writing to). Plus, in your case, you used single quotes to surround your "\n", so it didn't get interpolated.

Here's what I get:

% perl -i -p -e "BEGIN{print 'A new line!\n';}" foo A new line!\n%
I tried this myself, the other day, but ran into the same problem.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2022-08-19 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?