[Chicago-talk] Perl script cannot find itself?
tiger peng
tigerpeng2001 at yahoo.com
Fri Jun 17 08:19:48 PDT 2011
Thanks, You are right. (I thought after using vi to edit it, the \r should be gone)
/tmp>$ od -c test.pl
0000000 # ! / u s r / l o c a l / b i n
0000020 / p e r l \r \n s y s t e m ( '
0000040 w h i c h p e r l ' ) ; \r \n p
0000060 r i n t " h i \ n " ; \r \n
0000076
/tmp>$ perl -i -pe 's/\r//' test.pl
$ od -c test.pl
0000000 # ! / u s r / l o c a l / b i n
0000020 / p e r l \n s y s t e m ( ' w
0000040 h i c h p e r l ' ) ; \n p r i
0000060 n t " h i \ n " ; \n
0000073
/tmp>$ test.pl
/usr/local/bin/perl
hi
________________________________
From: Clyde Forrester <clydeforrester at gmail.com>
To: Chicago.pm chatter <chicago-talk at pm.org>
Sent: Friday, June 17, 2011 9:42 AM
Subject: Re: [Chicago-talk] Perl script cannot find itself?
I generally use the od -c command to check for stuff like that.
If you see "0d 0a" combinations instead of just "0a", then you have carriage returns.
od -c test.pl
c4
tiger peng wrote:
> I checked them with vi's list command, there is no cartridge return character in the scripts.
>
> ------------------------------------------------------------------------
> *From:* Andrew Rodland <andrew at cleverdomain.org>
> *To:* Chicago.pm chatter <chicago-talk at pm.org>
> *Sent:* Thursday, June 16, 2011 9:19 PM
> *Subject:* Re: [Chicago-talk] Perl script cannot find itself?
>
> On Thursday, June 16, 2011 04:47:39 PM tiger peng wrote:
> > There are two Perl scripts only different by the first line. Why the one
> > without -w in the #! line cannot find itself but the own with -w can?
>
> Because you saved the file with windows line-endings, and there's a \cM at the
> end of every line. In the first case, the kernel is looking for
> "/usr/local/bin/perl\cM" and can't find it. In the second case the kernel is
> looking for "/usr/local/bin/perl" and running it with an argument of "-w\cM",
> which is harmless.
_______________________________________________
Chicago-talk mailing list
Chicago-talk at pm.org
http://mail.pm.org/mailman/listinfo/chicago-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20110617/f5d8b421/attachment.html>
More information about the Chicago-talk
mailing list