Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Copying an ascii text file, replicating end of line terminator (windows or unix)

by Eily (Monsignor)
on Jul 24, 2015 at 08:52 UTC ( [id://1136141]=note: print w/replies, xml ) Need Help??


in reply to Copying an ascii text file, replicating end of line terminator (windows or unix)

The output record separator may help you do what you want:

$\ = $endofline; print OUTFILE $processed_string; # Appends the wanted end of line corr +ectly
This may be a problem if you are not writing to OUTFILE only while $\ is changed. If you can limit the change to a defined scope (ie: localize) that would probably be better:
{ local $\ = $endofline; my $old_handle = select OUTFILE; # Write to OUTFILE only while (<>) { process($_); print $_; # write to selected handle (OUTFILE) and append $\ } select $old_handle; } # $\ has its old value again

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-23 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found