Need to extract only the function name no brackets reqd.



Hi,
I have this program which extract function names from the files.
My only problem is I want to extract only the function names{no
brackets () needed } .
Currently its extract all words after word sub but it all
returns
the parentheses after that.


my $fileLoc = "//opt//sva//perl//lib//" ;
my $funcCount = 0 ;

opendir (DIR, $fileLoc) || die "Cannot opendir $!" ;
my @libs = readdir(DIR) ;

open (RES, ">out.txt") || die "Cannot open out.txt : $!" ;

foreach (@libs){
if(/pm$/){
open(FILE, $fileLoc.$_) or die("Unable to open $!") ;

print RES "Inside file >> $_ \n" ;
while (<FILE>){
chomp ;
if (/sub/){
my $sub ;
my $subName ;
($sub, $subName) = split /\s+/ ;
# print RES $_ ."\n" ;
print RES $subName."\n" ;
$funcCount ++ ;
}
}
print "\n\n" ;
close(FILE) ;
}

}

print RES "Total Functions : $funcCount \n" ;
close RES ;
closedir DIR ;

Thanks
Alok

.



Relevant Pages