Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^6: Global vs. local?

by Corion (Patriarch)
on May 29, 2009 at 17:52 UTC ( [id://766903]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Global vs. local?
in thread Global vs. local?

While the name is weird, if you're using a variable to hold it, you can perfectly call the subroutine through that name. And using weird names is good for named subroutines that get autogenerated by code:

my $subname = '1Button_Click'; *{$subname} = sub { print "Hello World\n"; }; no strict 'refs'; $subname->();

Replies are listed 'Best First'.
Re^7: Global vs. local?
by shmem (Chancellor) on May 29, 2009 at 18:04 UTC
    And using weird names is good for named subroutines that get autogenerated by code

    The question is wether it is good to name subroutines autogenerated by code in the symbol table. With a dispatch table hash you can name your subroutines by chunks of jpeg files, nice. But symbol tables are namespaces and their entries good for importing/exporting/localizing. I'd rather expect programmers to adhere to perl principles here.

    Q: Why do you do that?
    A: Because I can!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-16 14:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found