Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

(tye)Re: Using perl's runtime options with -Mstrict

by tye (Sage)
on Jan 27, 2001 at 03:29 UTC ( #54676=note: print w/replies, xml ) Need Help??

in reply to Using perl's runtime options with -Mstrict

-s is for one-liners (and even then isn't very useful). -Mstrict is not for one-liners. The two are pretty much completely incompatible. However, you could just write:

#!/usr/bin/perl -ws use strict; # My supported command-line switches: use vars qw( $switch $help $debug $foo ); $switch= "hooray" unless $switch;
I see no reason to have a global $switch that Perl creates and then have a different, same-named lexical that you create with my.

Note that anyone using your script can accidentally type

minus-ess -snitch -helf -debung -food
and your program will silently act just like they hadn't included any command-line switches (that is, unless your program also defines a global named, for example, $food, and then relies on it to be initially uninitialized).

In other words, I don't consider this even close to a good design decision. ):

        - tye (but my friends call me "Tye")

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2021-10-21 14:02 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (83 votes). Check out past polls.