use strict; use warnings; use Regexp::Common qw/balanced/; while () { chomp; next if ! /($RE{balanced}{-parens=>'()'})/ or $1 =~ /^\("/; print "$_\n"; } __DATA__ blah.boo(getSomething()) blah.boo("getSomething") blah.boo(getSomething("something else")) blah.boo("getSomething()")