Perl doesn't know you mean to pass a filehandle to that method, so it passes the bareword "TR" instead. You could try to pass \*TR instead.
$ftp->put(\*TR,$File);
Better yet, for a recent enough perl, use a lexical variable to hold the filehandle. It'll look cleaner.
open my($tr), "unix2dos $File |" or die $!; # Or FQ path
$ftp->binary(); # We translate, not the server.
$ftp->put($tr,$File); # must give remote name.
But, IMO, it's overkill to call an external program to
handle this little task. Perl will convert line endings for you, when reading from a handle in text mode. Internally, on Windows, text data is Unix text data. So, all you need to do is open the file.
open my($fh), $File or die $!;
$ftp->binary(); # We translate, not the server.
$ftp->put($fh,$File); # must give remote name.
p.s. I really wonder why just transferring data in Ascii mode won't work. Are you sure you don't accidently have double carriage returns in your files?
|