Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Having to remove \r from $ARGV[-1]

by bart (Canon)
on Nov 15, 2012 at 12:48 UTC ( #1004005=note: print w/ replies, xml ) Need Help??


in reply to Having to remove \r from $ARGV[-1]

You can add a space at the end of the line, that'll probably take care of it. Unless your editor is set to drop trailing spaces...

More reliable is to use " --" to tell GetOptions that there are no more options. In that case, the trailing CR will probably be ignored.

Note that in a more recent perl (= less than a few years old), CR inside source code is automatically handled, because in older perls, it did choke on it (e.g. when running a Windows text script on Linux). But not for the shebang line (and I honestly don't know what happens now, with multiline strings).

Of course if you had a bit of discipline and set the line endings to Unix in your text editor, you wouldn't have this problem. Most decent text editors allow you to chose a default line ending for new file, or, I would hope so.


Comment on Re: Having to remove \r from $ARGV[-1]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004005]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2015-07-01 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (25 votes), past polls