http://qs1969.pair.com?node_id=1004004

JPMH has asked for the wisdom of the Perl Monks concerning the following question:

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 ?

Unless I put $ARGV[-1] =~ s/\r//; at the top of my subroutine before getting the command-line arguments from GetOptions(), 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.

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.

But presumably this can't be that 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 ?