my @subnames; #open this source file open FILE, '/perlsource.pl/'; while () { #if sub name push onto array of sub names if ($_=~/sub\s+(\S+)\s+\{/) { push @subnames, $1; } } close FILE;