Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by herveus (Prior)
on Jun 01, 2015 at 17:03 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1128602]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-23 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found