Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Strict, strings and subroutines

by graq (Curate)
on Oct 10, 2001 at 16:15 UTC ( #117977=note: print w/ replies, xml ) Need Help??


in reply to Strict, strings and subroutines

You could try using an eval.

#!/usr/bin/perl -w use strict; my $type = 'hatter'; my $arg = 'using eval'; my $proc = "do_$type"; eval "$proc( \$arg )"; die( "Eval errored: $@" ) if $@; sub do_hatter { my( $foo ) = @_; print "This can be done $foo.\n"; }
Hope this helps.

--
Graq


Comment on Re: Strict, strings and subroutines
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://117977]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2016-02-06 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?





    Results (220 votes), past polls