If you use a hash of subroutine references you can then use the names as keys in the hash.
#! /usr/bin/perl -w -T use strict; my %subs = ( foo => sub { print "Foo!\n" }, bar => sub { print "Bar!\n" }, ); while ( my $sub_name = <DATA> ) { chomp($sub_name); if ( defined($subs{$sub_name}) ) { &{$subs{$sub_name}}; } } __DATA__ foo bar
In reply to Re: dynamic perl calls
by pileofrogs
in thread dynamic perl calls
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |