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

Re^3: How can I call a Perl sub with an object from a sub name stored in a var?

by stevieb (Canon)
on Dec 08, 2020 at 18:51 UTC ( [id://11124852]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How can I call a Perl sub with an object from a sub name stored in a var?
in thread How can I call a Perl sub with an object from a sub name stored in a var?

One thing I forgot to mention is that the variable that encompasses the name of the subroutine should somehow reflect which sub it represents.

Doing something like the following in a file with hundreds or thousands of lines of code can be frustratingly confusing:

my $method_1 = 'twist_rubber_arm'; my $var_6 = 'choke_chicken'; my $x = 'let_cat_out_of_bag'; # far, far later on in the code say $object->$var_6('tomorrow');

What the hell is $var_6 again?!? Time to go wading through code. Even with a good editor/IDE, backtracking is a time sink. Best to use names that are clearly representative in some way (as with all variables regardless if they map to a subroutine or not).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found