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

Re: Re: Re: Re: Flag variables

by BrowserUk (Patriarch)
on Mar 03, 2003 at 21:05 UTC ( [id://240159]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Flag variables
in thread Flag variables

Using the hash reference to return the sub name...

It's worth pointing out that it doesn't actually return the name of the sub, but rather a coderef for the sub.

Whilst you could name the subs with the same name as the value used to look them up, and then avoid the need to use the hash at all, that would be an example of using symbolic references with all the inherent dangers that implies.

By storing and looking up a coderef to the action subroutines, you avoid the possibility of attempting to invoke a non-existant subroutine if $var has an unexpected value and more importantly, avoid the possibility of invoking one of the potentially dangerous built-ins if the contents of $var has been deliberately tampered with.


Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
3) Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-20 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found