Variable variable name
Joe Oppegaard
joe at joppegaard.com
Wed Jul 3 19:56:51 CDT 2002
On Wed, 3 Jul 2002, Jason White wrote:
> How can I use the variable $functionToCall to replace ??????? with foo( ) ?
>
You can make the variable a reference to a subroutine, then just deref
it as a sub to call it, like:
#!/usr/bin/perl -w
use strict;
my $functionToCall = \&foo;
$functionToCall->();
sub foo {
print "FOO!\n";
}
--
-Joe Oppegaard
http://joppegaard.com
TIMTOWTDI
More information about the Pdx-pm-list
mailing list