<?xml version="1.0" encoding="windows-1252"?>
<node id="1004004" title="Having to remove \r from $ARGV[-1]" created="2012-11-15 07:37:34" updated="2012-11-15 07:37:34">
<type id="115">
perlquestion</type>
<author id="1003638">
JPMH</author>
<data>
<field name="doctext">
&lt;p&gt;I find I'm having to explicitly remove \r from $ARGV[-1] before Getopt::Long will process command lines properly from a shell script.  Is this normal ?&lt;/p&gt;

&lt;p&gt;Unless I put 
&lt;code&gt;$ARGV[-1] =~ s/\r//;&lt;/code&gt;
at the top of my subroutine before getting the command-line arguments from &lt;code&gt;GetOptions()&lt;/code&gt;, GetOptions can't cope with the extra \r there.  So for example if the final argument is a filename, then 'filename\r' gets passed back instead of the filename itself, which then can't be found.&lt;/p&gt;

&lt;p&gt;Admittedly, I probably have myself to blame, by running sh scripts on Cygwin to call my perl scripts, but using a Windows editor to write them, and not being careful to specify any particular linefeed behaviour.&lt;/p&gt;

&lt;p&gt;But presumably this can't be &lt;i&gt;that&lt;/i&gt; uncommon.  Should I be surprised at having to strip the extra '\r's by hand, rather than being able to leave it all to GetOptions ?&lt;/p&gt;

</field>
</data>
</node>
