Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Is using '-s' really bad and why?

by Anonymous Monk
on Oct 18, 2004 at 17:20 UTC ( #400234=note: print w/replies, xml ) Need Help??

in reply to Is using '-s' really bad and why?

Well, here are some of my thoughts and attempts, some might be a good argument, others might not be (depending on the situation and the code).

First, I wondered what would happend if some of the predefined variables are changed (as in passed as an argument), but then I thought of changing variables in another package.
When I passed the argument -Abc::Def::ghi=jkl then the variable $Abc::Def::ghi was changed, at this moment I'm too lazy to find out what would happend if Abc::Def was a real package, which does rely on the value...

Now, back to the builin variables,

  • Argument -[=45, nothing happend.
  • Argument -,=abc: $, was changed to "abc", but "abc" wasn't used as list seperator in print @x; which means that print join $,, @x; isn't the same as print @x;
  • Argument -\"=abc: $" was changed to "abc", and print "@x" was the same as join $", @x;, or in other words, the value was changed and is used.
  • Argument -#=%06d (that var is deprecated but I tried it anyway): value of $# is changed but not used
  • Argument -]=2.019: value changed, 'use 5.006' still uses the correct version, but if ($] < 5.006) will fail. And particulary intresting about this is that $] is a read-only value

These are just some vars from perldoc perlvar on which there probably isn't checking and can effect the output/working of the script...

But aslong as -s is used with care (as in not in public scripts which may be run by others) I don't see any problem using -s, ofcourse it is a lot safer to use a GetOpt module, which is what I usually do.

Also I don't think -s is the top hit on google, I rather think it is either one of the following: -p, -e, -n, -i or -l. (Or atleast those are the ones which I reguarally use).

Replies are listed 'Best First'.
[OT] Re^2: Is using '-s' really bad and why?
by DaveH (Monk) on Oct 18, 2004 at 17:31 UTC

    Wouldn't searching for '-s' on Google be rather futile?

    Just a thought... ;-)


    -- Dave :-)

      Search for "-s" then :)

      You want a futile search, try to search for "The Who", when "The" is too common a word, and so is "Who". Quotes are useless. You'd be better off searching for Daltry and Townsend, which is useless if you didn't know Who The Who Were, and you couldn't Guess Who (pun intended) was in the Who.

      Amazon is just as bad. Try searching for "The Band".

        Regarding searching for The Who.
        Add a + in front of your search -
        ie +"The Who"
        From the same page quoted above:

        If a common word is essential to getting the results you want, you can + include it by putting a "+" sign in front of it. (Be sure to include + a space before the "+" sign.)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2020-12-01 12:19 GMT
Find Nodes?
    Voting Booth?
    How often do you use taint mode?

    Results (6 votes). Check out past polls.