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

Re^4: Best option for "switch/case" functionality? (BEGIN)

by tye (Sage)
on Jun 29, 2016 at 02:28 UTC ( [id://1166832]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Best option for "switch/case" functionality? (magic numbers)
in thread Best option for "switch/case" functionality?

Nope. Otherwise, 'use' couldn't work as it is just syntactic sugar for pretty much what I wrote (well, 'no' more than 'use' in this case). Now, if you put 'use' in a BEGIN block, then it could have impacts lexically scoped to the BEGIN block, but that is because it would be short for:

BEGIN { BEGIN { require ...; ...->import( ... ) } }

- tye        

Replies are listed 'Best First'.
Re^5: Best option for "switch/case" functionality? (BEGIN)
by Anonymous Monk on Jun 29, 2016 at 05:25 UTC
    The eval block?

      Maybe instead of tossing off random questions, why don't you try it and see? I already did that before I posted it.

      If I wanted to make it lexically scoped to the 'eval' block, then I'd have to write:

      BEGIN { eval { BEGIN { require ...; ...->import( ... ) } ... } }

      Which, of course, I didn't.

      - tye        

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-03-28 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found