http://qs321.pair.com?node_id=407916

jobi has asked for the wisdom of the Perl Monks concerning the following question:

Masterly Mindful Monks,

The following code is what this novice has managed to glean from reading The Holy Perldoc referencing references.

Now, the question that's eluding the novice's mind is whether 'tis possible to rid the code of that annoying my $coderef = \&$_; line, and do the referencing/dereferencing in one fell swoop?

This novice realizes that this could be done by banishing the line use strict; from the code, but that beautiful flower should really be kept blossoming in the garden of the Monastery, and not be trampled down needlessly.

Peace, Love and Perl,
jobi
#!/usr/bin/perl use warnings; use strict; my @list = qw/one two three/; foreach (@list) { my $coderef = \&$_; &$coderef($_); } sub one { my $number = shift; print "Sub $number reporting for duty.\n" } sub two { my $number = shift; print "Sub $number reporting for duty.\n" } sub three { my $number = shift; print "Sub $number reporting for duty.\n" }