The trick is knowing that you can access a symbol table with %main:: or %packagename:: or %:: for the current package.#!/usr/bin/perl -w use strict; my $name = "chromatic"; my $quest = "nefarious symbol wrangling"; sub findme { # just has to be defined return 0; } foreach (keys %main::) { # use whichever package you prefer no strict 'refs'; # else the next line fails if (defined *{$_}{CODE}) { print "$_\n"; # could be pushed onto an array, into a h +ash } }
The typeglob trickery in the defined line just looks to see if there's a CODE bit in the current package.
Personally, I'd just keep a hash of subroutine names and references around:
my %subs = ( mod_disk => \&mod_disk, mod_ram => \&mod_ram, mod_sticky_note => \&mod_sticky_note, mod_gum_wrapper => \&mod_gum_wrapper );
In reply to (chromatic) Re: Looping on function names
by chromatic
in thread Looping on function names
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |