Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Why to wrap Perl classes inside a Perl script into blocks

by herveus (Parson)
on Jun 01, 2015 at 17:03 UTC ( #1128602=note: print w/replies, xml ) Need Help??


in reply to Why to wrap Perl classes inside a Perl script into blocks

Howdy!

You're on the right track. However, lexical variables' scope is delimited by the blocks. package does not make a new scope.

Consider:

{ package Foo; my $foo; } { package Bar; my $foo; # new $foo not to be confused with one above }

Versus:

package Foo; my $foo; package Bar; my $foo; # my declaration masks previous one

yours,
Michael

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2020-05-29 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (169 votes). Check out past polls.

    Notices?