copying files from Unix to Win system
mikeraz at patch.com
mikeraz at patch.com
Mon Jun 24 11:24:24 CDT 2002
Hi All,
I'm automating a process that receives text files via ftp and then mounts
a SAMBA share to copy the files to a Windows based file server.
The current method is open file, set $/ to "", slurp file, write file and close:
open INFILE, "<$_" or die "cannot open local $_";
open OUTFILE, ">$tmnt/$dest/$_" or die "cannot open destination $_";
$fs = $/;
undef $/;
$cont = <INFILE>;
print OUTFILE $cont;
$/ = $fs;
close INFILE;
close OUTFILE;
Problem with this approach is that the line endings are not converted. Same
problem for
while(<INFILE>) {
print OUTFILE;
}
While I'm scratching my head over why this isn't being done automagically,
I'm considering:
@lines_in_file = <INFILE>;
foreach (@lines_in_file) {
chomp;
}
$/ = "\015\012"; # from newlines in perlport
foreach (@lines_in_file) {
print OUTFILE "$_$/";
}
But that feels wrong as in there has to be a better way wrong.
Now if someone is going to tell me that Perl has a built in file copy funcation . . . .
--
Michael Rasmussen aka mikeraz
Be appropriate && Follow your curiosity
"They that give up essential liberty to obtain
temporary safety, deserve neither liberty nor safety."
-- Benjamin Franklin
and the fortune cookie says:
"The chain which can be yanked is not the eternal chain."
-- G. Fitch
TIMTOWTDI
More information about the Pdx-pm-list
mailing list