perlquestion
JPMH
<p>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 ?</p>
<p>Unless I put
<code>$ARGV[-1] =~ s/\r//;</code>
at the top of my subroutine before getting the command-line arguments from <code>GetOptions()</code>, 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.</p>
<p>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.</p>
<p>But presumably this can't be <i>that</i> 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 ?</p>