I must admit I'm confused by the intent of theleftsock (who seems to have chosen a very complicated way to do a fairly simple thing), but I'm also confused by the intent of the extra lexical scalar $returned_hash_ref present in your reply. What does this give you (other than another maintenance worry) that you do not get from the hash and key you already have in hand?
>perl -wMstrict -le "sub S { print 'hi ', $_[0] } sub T { print 'lo ', $_[0] } sub U { print '-- ', $_[0] } my %hash = ( my $x = L => \&S, my $y = M => \&T, my $z = N => \&U, ); print $x; $hash{$x}->($x); $hash{L} ->('L'); $hash{$_}->($_) for qw(L M N); " L hi L hi L hi L lo M -- N
In reply to Re^2: use strict refs unless you can't figure out the syntax
by AnomalousMonk
in thread use strict refs unless you can't figure out the syntax
by theleftsock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |