Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: strict

by dimmesdale (Friar)
on Jul 24, 2002 at 22:07 UTC ( [id://185049]=note: print w/replies, xml ) Need Help??


in reply to Error when using strict pragma

you have to say my $opt_u, or the compiler will spit an error -- or you could say (assuming main package) $MAIN::opt_u and be gone with it.

This is because use strict requires you're variables to be declared -- or, as I think on it, you could say use vars qw/$opt_u ... others here.../; (hey, TMTOWTDI :)

May I suggest, however, that (I assume you're using a GetOpt:: module here) you don't let the GetOpt module assign $opt_<whatever>, but instead pass it a hash reference. This way you can say $opts->{<whatever>} and be done with it.

Replies are listed 'Best First'.
Re: Re: strict
by Bird (Pilgrim) on Jul 25, 2002 at 18:28 UTC
    I agree that you're probably better off just getting your opts out of the hash, but to clear up your initial comment, I'm pretty sure the (official/newest) way to declare it would be...

    our $opt_u;

    This makes it global and is necessary since you want to be accessing the same variable that Getopt is using.

    -Bird

    Update: Just read the comment by dws below. I was thinking of Getopt::Std. I have no idea how GetOpt works.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-18 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found