while () { chomp; $_ =~ s/^&(\w+)([\(\)]*)/$1()/; print "$_\n"; } __DATA__ &foobar &foobar() foobar() &foobar("asdf") #### foobar() foobar() foobar() foobar()"asdf") #### while () { chomp; $_ =~ s/^(&)(\w+(\([\"\'\$\w]*\))?)(\(\))$/$2()/; print "$_\n"; } #### &foobar foobar() foobar() &foobar("asdf")