<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
I'm just pass this along in case any of you <br>
are interested in this. It has something to do <br>
with PAR::_run_member using a filehandle opened in binmode.<br>
<br>
binmode DATA, ':crlf';<br>
would reportedly fix it, but I did<br>
<div class="moz-forward-container">s/[\r\n]+$//;<br>
in my code instead. That fixed it for me.<br>
<br>
This is apparently a Windows issue that does not affect Linux, <br>
I think.<br>
<br>
<br>
<br>
<br>
-------- Forwarded Message --------
<table class="moz-email-headers-table" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject:
</th>
<td>Re: Par not working on Net::FTP::Recursive Script</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date: </th>
<td>Sat, 08 Aug 2015 07:12:27 -0500</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">From: </th>
<td>Mike Flannigan <a class="moz-txt-link-rfc2396E" href="mailto:mikeflan@att.net"><mikeflan@att.net></a></td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">To: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:par@perl.org">par@perl.org</a></td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">CC: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:shawn.laffan@unsw.edu.au">shawn.laffan@unsw.edu.au</a></td>
</tr>
</tbody>
</table>
<br>
<br>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<br>
<div class="moz-cite-prefix">On 8/8/2015 1:36 AM, <a
moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="mailto:par-digest-help@perl.org">par-digest-help@perl.org</a>
wrote:<br>
</div>
<blockquote cite="mid:1439015792.2444.ezmlm@perl.org" type="cite">This
is a more general problem than PAR. <br>
<br>
I've had similar issues with input files when I was alternating
between cygwin and normal windows in the distant past.
Data::Section::Simple also does the same thing, in that it does
not translate crlf endings when loading from a data block on
linux. I expect there are many other ways of hitting this
issue.<br>
<br>
The solution I use is to remove the crlf line endings in my
code, e.g.:<br>
<br>
s/[\r\n]+$// for @data;<br>
<br>
or, more verbosely but more clearly:<br>
<br>
for my $item (@data) {<br>
$item =~ s/[\r\n]+$//;<br>
}<br>
<br>
Regards,<br>
Shawn.</blockquote>
<br>
<br>
Thanks for that fix. I was too lazy to carry this forward <br>
until I saw your e-mail. Of course it worked. The script <br>
works in both PAR and regular Perl when putting that regex <br>
in there.<br>
<br>
Thanks to everyone for all the help.<br>
<br>
<br>
For my records I have summarized most of the e-mails on this <br>
subject below.<br>
<br>
<br>
Mike<br>
<br>
<br>
<br>
<br>
<hr size="2" width="100%"><br>
<br>
<br>
<table class="header-part1" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Subject:
</div>
Par not working on Net::FTP::Recursive Script</td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">From:
</div>
Mike Flannigan <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:mikeflan@att.net"><mikeflan@att.net></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Date:
</div>
8/2/2015 12:51 PM</td>
</tr>
</tbody>
</table>
<table class="header-part2" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">To:
</div>
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="mailto:par@perl.org">par@perl.org</a></td>
</tr>
</tbody>
</table>
<br>
<br>
I have a script that runs fine in Perl64, but when I do <br>
<br>
pp -o uploadfiles.exe inputfile.pl <br>
<br>
and try to run uploadfiles.exe it opens a prompt <br>
box and tries to connect to a HostGator account, <br>
but after a few seconds gives <br>
"login authentication failed". <br>
<br>
The script uses this: <br>
<br>
use strict; <br>
use warnings; <br>
use File::Find; <br>
use Net::FTP::Recursive; <br>
$| = 1; #Autoflush STDOUT <br>
<br>
<br>
Anybody have any ideas on why this is not working? <br>
This is Activestate Perl 5.16.3 built for <br>
MSWin32-x64. <br>
<br>
<br>
Mike <br>
<br>
<hr size="2" width="100%"><br>
<br>
<br>
<table class="header-part1" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Subject:
</div>
Re: Par not working on Net::FTP::Recursive Script</td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">From:
</div>
Roderich Schupp <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:roderich.schupp@gmail.com"><roderich.schupp@gmail.com></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Date:
</div>
8/2/2015 2:03 PM</td>
</tr>
</tbody>
</table>
<table class="header-part2" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">To:
</div>
Mike Flannigan <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:mikeflan@att.net"><mikeflan@att.net></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">CC:
</div>
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org">"par@perl.org"</a> <a
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org"><par@perl.org></a></td>
</tr>
</tbody>
</table>
<br>
<div class="gmail_extra">On Sun, Aug 2, 2015 at 7:51 PM, Mike
Flannigan <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mikeflan@att.net" target="_blank">mikeflan@att.net</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":cf" class="a3s" style="overflow:hidden">The script
uses this:<br>
</div>
</blockquote>
</div>
<br>
</div>
<div class="gmail_extra">Not enough information. For instance, how
does it "open a prompt box"?<br>
</div>
<div class="gmail_extra">Try cutting the script down to a minimal
example that exhibits the problem.<br>
<br>
</div>
Cheers, Roderich<br>
<br>
<br>
<hr size="2" width="100%"><br>
<br>
<br>
<table class="header-part1" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Subject:
</div>
Re: Par not working on Net::FTP::Recursive Script</td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">From:
</div>
Mike Flannigan <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:mikeflan@att.net"><mikeflan@att.net></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Date:
</div>
8/2/2015 6:09 PM</td>
</tr>
</tbody>
</table>
<table class="header-part2" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">To:
</div>
Roderich Schupp <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:roderich.schupp@gmail.com"><roderich.schupp@gmail.com></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">CC:
</div>
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org">"par@perl.org"</a> <a
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org"><par@perl.org></a></td>
</tr>
</tbody>
</table>
<br>
<br>
<br>
In Windows when you double click on a par exe file it opens <br>
a command prompt box to show the results of the script.<br>
<br>
I guess a minimalist script would be as follow:<br>
<br>
use strict;<br>
use warnings;<br>
use Net::FTP::Recursive;<br>
<br>
my $ip="142.146.2.103";<br>
my $username="user";<br>
my $pass="pass";<br>
<br>
my $ftp = Net::FTP::Recursive->new($ip, Passive => 1, Debug
=> 0);<br>
<br>
$ftp->login($username, $pass) or die $ftp->message;<br>
<br>
print "All done.\n\a";<br>
<br>
__END__<br>
<br>
<br>
Interestingly, this seems to work in the par exe created <br>
from this file.<br>
<br>
<br>
OK, I haven't figured it out 100% yet, but it appears to have <br>
something to do with the newline at the end of each of these <br>
lines:<br>
<br>
__DATA__<br>
BkmTNBOhAQjsn3YUJWA9cw2JDp8lcw<br>
Jx7ecihoLGsWidVUgRDl5CI38mpLbF<br>
23X7p1HDSwXgGg4z8xSNshVBQScLCB<br>
MkNyVS4Dnkx55TsW1VfCVm7niOU777<br>
<br>
In my Windows Perl environment when I count <br>
22 characters forward, I get the character I expect <br>
to get. In the par environment, when I count <br>
22 characters forward I get the character at position 21 <br>
instead (if it goes past the end of one of the lines). Perhaps <br>
this has something to do with a newline being interpreted as <br>
\n\r or \n or \cJ or whatever.<br>
<br>
I'm probably going to have an ugly work-around for this. Or <br>
perhaps I can come up with a more elegant work-around when <br>
using par. We will see.<br>
<br>
Thanks for your help.<br>
<br>
<br>
Mike<br>
<br>
<br>
<hr size="2" width="100%"><br>
<br>
<br>
<table class="header-part1" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Subject:
</div>
Re: Par not working on Net::FTP::Recursive Script</td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">From:
</div>
Roderich Schupp <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:roderich.schupp@gmail.com"><roderich.schupp@gmail.com></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Date:
</div>
8/3/2015 9:44 AM</td>
</tr>
</tbody>
</table>
<table class="header-part2" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">To:
</div>
Mike Flannigan <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:mikeflan@att.net"><mikeflan@att.net></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">CC:
</div>
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org">"par@perl.org"</a> <a
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org"><par@perl.org></a></td>
</tr>
</tbody>
</table>
<br>
<div class="gmail_extra">On Mon, Aug 3, 2015 at 1:09 AM, Mike
Flannigan <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mikeflan@att.net" target="_blank">mikeflan@att.net</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">OK, I haven't figured
it out 100% yet, but it appears to have <br>
something to do with the newline at the end of each of
these <br>
lines:<br>
<br>
__DATA__<br>
BkmTNBOhAQjsn3YUJWA9cw2JDp8lcw</div>
</blockquote>
</div>
<br>
</div>
<div class="gmail_extra">Good observation! I packed the following
script (and checked that it has Windows CRLF line endings)<br>
<br>
</div>
<div class="gmail_extra">--- snip ---<br>
</div>
<div class="gmail_extra">use strict;<br>
</div>
<div class="gmail_extra">use warnings;<br>
</div>
<div class="gmail_extra">use Data::Dumper;<br>
</div>
<div class="gmail_extra">$Data::Dumper::Useqq = 1;<br>
</div>
<div class="gmail_extra">my @data = <DATA>;<br>
</div>
<div class="gmail_extra">print Dumper(\@data);<br>
</div>
<div class="gmail_extra">__DATA__<br>
</div>
<div class="gmail_extra">fooy<br>
</div>
<div class="gmail_extra">bar<br>
</div>
<div class="gmail_extra">quux<br>
</div>
<div class="gmail_extra">
<div class="gmail_extra">--- snip ---<br>
<br>
</div>
<div class="gmail_extra">$ perl <a moz-do-not-send="true"
href="http://data.pl">data.pl</a><br>
$VAR1 = [<br>
"foo\n",<br>
"bar\n",<br>
"quux\n"<br>
];<br>
<br>
</div>
<div class="gmail_extra">but when I pack it<br>
<br>
</div>
<div class="gmail_extra">$ pp -o data.exe <a
moz-do-not-send="true" href="http://data.pl">data.pl</a><br>
</div>
<div class="gmail_extra">$ .\data.exe<br>
$VAR1 = [<br>
"foo\r\n",<br>
"bar\r\n",<br>
"quux\r\n"<br>
];<br>
<br>
</div>
<div class="gmail_extra">I checked the script as packed into
data.exe and it has its CRLF endings intact.<br>
</div>
But the hack that's used to actually run it (i.e.
PAR::_run_member) uses a filehandle opened in binmode. <br>
Looks like the implicit DATA filehandle inherits this setting
somehow.<br>
<br>
</div>
<div class="gmail_extra">I'll have to think some more whether
changing PAR::_run_member might have side effects.<br>
<br>
</div>
<div class="gmail_extra">Cheers, Roderich<br>
</div>
<div class="gmail_extra"><br>
<br>
<br>
<hr size="2" width="100%"><br>
<br>
<table class="header-part1" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Subject:
</div>
Re: Par not working on Net::FTP::Recursive Script</td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">From:
</div>
Mike Flannigan <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:mikeflan@att.net"><mikeflan@att.net></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Date:
</div>
8/3/2015 5:33 PM</td>
</tr>
</tbody>
</table>
<table class="header-part2" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">To:
</div>
Roderich Schupp <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:roderich.schupp@gmail.com"><roderich.schupp@gmail.com></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">CC:
</div>
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org">"par@perl.org"</a> <a
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org"><par@perl.org></a></td>
</tr>
</tbody>
</table>
<br>
<br>
<br>
Thanks for confirming that. Chomp certainly doesn't fix <br>
the problem. Oddly I couldn't get the variable I wanted <br>
no matter what I did! I always got the variable in front of <br>
or behind the one I wanted, even though I only moved the <br>
array index by one.<br>
<br>
I finally gave up and removed all the newlines. I just <br>
put all the data on one line now.<br>
<br>
It's a bit frustrating, but I have my fix.<br>
I'm surprised I was the one to point this out.<br>
Must be very few of us Windows par users.<br>
<br>
<br>
Mike<br>
<br>
<br>
</div>
<br>
<hr size="2" width="100%"><br>
<br>
<table class="header-part1" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Subject:
</div>
Re: Par not working on Net::FTP::Recursive Script</td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">From:
</div>
Roderich Schupp <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:roderich.schupp@gmail.com"><roderich.schupp@gmail.com></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Date:
</div>
8/4/2015 9:03 AM</td>
</tr>
</tbody>
</table>
<table class="header-part2" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">To:
</div>
Mike Flannigan <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:mikeflan@att.net"><mikeflan@att.net></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">CC:
</div>
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org">"par@perl.org"</a> <a
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org"><par@perl.org></a></td>
</tr>
</tbody>
</table>
<br>
<div class="gmail_extra">On Tue, Aug 4, 2015 at 12:33 AM, Mike
Flannigan <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mikeflan@att.net" target="_blank">mikeflan@att.net</a>></span>
wrote:<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">Thanks for confirming
that. Chomp certainly doesn't fix <br>
the problem. </div>
</blockquote>
</div>
<br>
</div>
<div class="gmail_extra">chomp won't help, in my example it will
only get you from<br>
<br>
$VAR1 = [<br>
"foo\r\n",<br>
"bar\r\n",<br>
"quux\r\n"<br>
];<br>
<br>
</div>
<div class="gmail_extra">to <br>
<br>
$VAR1 = [<br>
"foo\r",<br>
"bar\r",<br>
"quux\r"<br>
];<br>
<br>
</div>
<div class="gmail_extra">By default, chomp doesn't strip CR LF, as
$/ is "\n" even on Windows.<br>
</div>
<div class="gmail_extra">Reading a file on Windows in non-binmode
will convert CR LF to "\n".<br>
</div>
<div class="gmail_extra"><br>
<br>
<div><br>
</div>
<div>My guess would be that the majority of PAR users is on
Windows, but using __DATA__ is rare.<br>
</div>
<div>Or at least using the data in a way that is susceptible to
CRLF v LF corruption.<br>
<br>
</div>
<div>Cheers, Roderich<br>
</div>
</div>
<br>
<br>
<hr size="2" width="100%"><br>
<br>
<br>
<br>
<table class="header-part1" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Subject:
</div>
Re: Par not working on Net::FTP::Recursive Script</td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">From:
</div>
Shawn Laffan <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:shawn.laffan@unsw.edu.au"><shawn.laffan@unsw.edu.au></a></td>
</tr>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">Date:
</div>
8/3/2015 6:44 PM</td>
</tr>
</tbody>
</table>
<table class="header-part2" border="0" cellpadding="0"
cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<div class="headerdisplayname" style="display:inline;">To:
</div>
<a moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:par@perl.org"><par@perl.org></a></td>
</tr>
</tbody>
</table>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 4/08/2015 8:33, Mike Flannigan
wrote:<br>
</div>
<br>
<br>
This is a more general problem than PAR. <br>
<br>
I've had similar issues with input files when I was alternating
between cygwin and normal windows in the distant past.
Data::Section::Simple also does the same thing, in that it does
not translate crlf endings when loading from a data block on
linux. I expect there are many other ways of hitting this issue.<br>
<br>
The solution I use is to remove the crlf line endings in my code,
e.g.:<br>
<br>
s/[\r\n]+$// for @data;<br>
<br>
or, more verbosely but more clearly:<br>
<br>
for my $item (@data) {<br>
$item =~ s/[\r\n]+$//;<br>
}<br>
<br>
Regards,<br>
Shawn.<br>
<br>
<br>
<hr size="2" width="100%"><br>
<br>
<br>
</div>
No worries Mike. <br>
<br>
After a bit more thought, the whole process might be simplified by
adding the :crlf layer to the DATA handle in your code. This is set
by default on windows, but not on linux.<br>
<br>
e.g.:<br>
<br>
binmode DATA, ':crlf';<br>
<br>
while (my $line = <DATA>) {<br>
do_stuff($line);<br>
}<br>
<br>
<br>
A few more details are at <a class="moz-txt-link-freetext"
href="http://perldoc.perl.org/PerlIO.html#DESCRIPTION">http://perldoc.perl.org/PerlIO.html#DESCRIPTION</a><br>
<br>
Regards,<br>
Shawn.
</body>
</html>