http://www.perlmonks.org?node_id=487957

noslenj123 has asked for the wisdom of the Perl Monks concerning the following question:

I am parsing some c++ files and at one point I need to extract any subroutine calls in a subroutine.

My current strategy is:

foreach my $line ( @sub_code ) { foreach my $sub ( keys %SUBS ) { if ( $line =~ /[^a-zA-Z]$sub[^a-zA-Z]*\(/ ) { push( @subs, $ke +y ) } } }
Which extracts the subroutine calls okay but it ends up being called 15,427 times and take 64+ seconds.

So is there any way to tune that regex or perhaps I should find a regex strategy to capture all subroutine calls at once for a subroutine block?

Can you nudge a disciple in the right direction?