in reply to How to convert a symbolic reference to a hard reference
I see your question has been answered directly by a few other fine Monks, but I thought I might add something. If you'd like to get a coderef without using eval, you can use can. For example:
sub foo { print "Foo!\n"; } my $pkg = "main"; my $sub = "foo"; my $cr = $pkg->can($sub) or die "Can't find '$sub' in package '$pkg'\n"; $cr->();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to convert a symbolic reference to a hard reference
by ysth (Canon) on Nov 06, 2003 at 03:24 UTC |