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


in reply to Strict, strings and subroutines

I'd do this by creating a hash of references to the various subroutines like this:

sub do_x { print "processing x\n"; } sub do_y { print "processing y\n"; } my %subs = ( x => \&do_x, y => \&do_y );

Then when you know what type you're going to be processing, you can do something like this:

$subs{$type}->();
--
<http://www.dave.org.uk>

"The first rule of Perl club is you don't talk about Perl club."