Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Object attribute followerby kcott (Archbishop) |
on Apr 15, 2016 at 04:41 UTC ( [id://1160493]=note: print w/replies, xml ) | Need Help?? |
G'day CSmatthieu, Welcome to the Monastery. Here's a highly contrived example of how you might pass a hashref (e.g. your object), an arrayref (e.g. your attribute path), and a coderef (e.g. your logic) to a single subroutine.
Output:
As I said, this is highly contrived and only intended to show a technique (i.e. it's not a solution). By putting your equivalent of &generic_hash_logic in a module, you can share it amongst all your scripts: no need to "create a subroutine for each one". — Ken
In Section
Seekers of Perl Wisdom
|
|