if ($content =~ /^sub\s+(\w+)[^#]*(?:#(.*))?$/) { print "Subname: $1\n"; print "Comment: $2\n" if defined $2; }