in reply to Variable Subroutine
But your solution is fine as it stands (although you need to call the function in the sort block e.g sort { &$sort_network{$sortby} } keys %networks).sub by_num { my($x,$y) = ($a =~ /(\d+)/, $b =~ /(\d+)/); return $x <=> $y; } sub by_abc { return $a cmp $b; } my $f = 'by_num'; my @args = qw/ foo1 bar2 baz3 /; print "$f - ", sort($f @args), $/; $f = 'by_abc'; print "$f - ", sort($f @args), $/; __output__ by_num - foo1bar2baz3 by_abc - bar2baz3foo1
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Variable Subroutine
by tombmbdil (Beadle) on May 27, 2003 at 17:20 UTC |