Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: use vars (expound a bit?)

by ybiC (Prior)
on Jul 17, 2000 at 04:34 UTC ( #22802=note: print w/replies, xml ) Need Help??

in reply to use vars

I've employed both these methods for declaring variables with use strict, but like jeffa, am unclear on the difference(s) between my and use vars.

merlyn's response is, as always, authoritative and to the point. Would a grokful Monk expound a bit, to help an amatuer Perler understand?

Update: Oops - Autark explained very well the lexical vs. global aspect. That's what I get for composing a question and not posting till after finishing a good show on The History Channel. :^)

Now I'm merely confused on the main:foo part. To my knowledge, I've never "fully-qualified" a variable, yet my cobbled-up scripts work anyway. At the risk of asking a dumb question - under what circumstances is it necessary to fully qualify?

Replies are listed 'Best First'.
(chromatic) RE: Re: use vars (expound a bit?)
by chromatic (Archbishop) on Jul 17, 2000 at 08:22 UTC
    You would fully qualify a 'package' variable when you're in another package. For example, if you use the DBI module, you can access error information for the last call in $DBI::errstr. Presumably, your code is in the main:: package, or another self-defined package. Saying $DBI:: (variable name) tells Perl where to find (variable name), since it's not in the current package.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2020-10-27 21:02 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (258 votes). Check out past polls.