package Globwalker; use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(get_things get_subs get_scalars get_arrays get_hashes get_filehandles); $VERSION = '0.01'; sub get_things { my $thing = shift; my $pkg = shift || caller; my @things; no strict 'refs'; # WARNING: Deep magic here! while (my ($sym_name, $sym_glob) = each %{"${pkg}::"}) { push @things, $sym_name if defined *$sym_glob{$thing}; } @things; } sub get_subs { get_things('CODE', shift || caller) }; sub get_scalars { get_things('SCALAR', shift || caller) }; sub get_arrays { get_things('ARRAY', shift || caller) }; sub get_hashes { get_things('HASH', shift || caller) }; sub get_filehandles { get_things('IO', shift || caller) }; 1;