Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Scope in use

by RonW (Vicar)
on Sep 06, 2017 at 20:13 UTC ( #1198786=note: print w/replies, xml ) Need Help??


in reply to Re: Scope in use
in thread Scope in use

The following also works, though is equally surprising that it is needed.

my $lib; use lib $lib = '.';

This works because variables declared at one scope are accessible from scopes inside the declaring scope.

Unfortunately, there isn't a good way to change this. It can, and probably should be, documented in the page for use and, maybe, also in the page for the lib pragma.

(Maybe a warning could be added when parsing use to remind people that my inside use has no effect and suggest alternate syntax.)

Replies are listed 'Best First'.
Re^3: Scope in use
by LanX (Bishop) on Sep 06, 2017 at 22:34 UTC
    I think it's enough to document it together with scoping in general - Wherever that happens - as edge case of the "till the end of the surrounding block" rule.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1198786]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-12-13 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (381 votes). Check out past polls.

    Notices?