in reply to Trying to get around the "use strict 'refs'" Issue
#tested my %dispatch = ( INTEGER => \&checkInteger, DATE => \&checkDate, IPADDRESS => \&checkIpaddress, FOO => \&checkFoo ); my $type = "INTEGER"; my $answer = "44"; die "can't do $type" unless exists $dispatch{$type}; my $convAnswer = $dispatch{$type}->($answer); sub checkInteger { print "int" } sub checkDate { print "date" } sub checkIpaddress { print "ip" } sub checkFoo { print "foo" }
If you insist on using your no strict "refs" method it's only a matter of time before someone enters deleteAllFiles as the data type.
Edit: Damn. You're all too fast. Or is it that I'm too Slow?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trying to get around the "use strict 'refs'" Issue
by naikonta (Curate) on May 08, 2007 at 14:03 UTC | |
|
Re^2: Trying to get around the "use strict 'refs'" Issue
by qazwart (Scribe) on May 07, 2007 at 17:54 UTC | |
by chromatic (Archbishop) on May 07, 2007 at 18:27 UTC | |
by blazar (Canon) on May 07, 2007 at 18:48 UTC |