[Chicago-talk] Perl script cannot find itself?

tiger peng tigerpeng2001 at yahoo.com
Fri Jun 17 10:05:39 PDT 2011


I'd better to dig more about the vim, the tool I used every day.



________________________________
From: Brian Katzung <briank at kappacs.com>
To: chicago-talk at pm.org
Sent: Friday, June 17, 2011 11:13 AM
Subject: Re: [Chicago-talk] Perl script cannot find itself?


When the line endings are \r\n instead of just \n, vim sets the fileformat to dos instead of unix. This is why list mode didn't reveal them. To fix them using vim:

vim test.pl
:se ff=unix        (short form of ":set fileformat=unix")
:wq

  - Brian

On 2011-06-17 10:19, tiger peng wrote: 
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
>
>
>
>
_______________________________________________
Chicago-talk mailing list Chicago-talk at pm.org http://mail.pm.org/mailman/listinfo/chicago-talk

-- 
Brian Katzung, Kappa Computer Solutions, LLC
Leveraging UNIX, GNU/Linux, open source, and custom
software solutions for business and beyond
Phone: 877.367.8837 x1  http://www.kappacs.com 
_______________________________________________
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/49904385/attachment.html>


More information about the Chicago-talk mailing list