[ABE.pm] Per *Unix writing DOS files
Ricardo SIGNES
rjbs-perl-abe at lists.manxome.org
Mon Oct 4 19:29:04 CDT 2004
* Faber Fedor <faber at linuxnj.com> [2004-10-04T19:06:04]
> If I'm on a Linux box running a Perl script, writing out to a file via
> print, what is the Proper way of making the output file a "DOS file",
> e.g. with DOS EOL (\r\n, right? Or do I do ^M?).
Consult "perldoc perlvar" under $OUTPUT_RECORD_SEPARATOR. The variable
you want to muck about with is $\ and I suggest you localize it for the
block in which you write the file.
@data = gather_some_lines;
{
local $\ = "\r\n";
open my $dos_fh, '>', 'file_dos.txt'
or die "can't open file for writing: $!";
print $dos_fh @data;
}
--
rjbs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/archives/abe-pm/attachments/20041004/51d2af9e/attachment.bin
More information about the ABE-pm
mailing list