in reply to Perl Syntax/resources that we generally don't know or forget.
Seems that you "forgot" or "don't know" something as well, namely the value of /m. Furthermore, it seems you want a .* after the # as well, but not in combination with /s!## When we are looking on REGEXP for something that is after other, ## genreally "\n", we forget about the beggin of the string, ## that enables an occurrence that is not after "\n". ## Soo, to do this in only one REGEXP we use (?:^|\n) ## remove comments: $str =~ s/(?:^|\n)[ \t]*#//gs
I'd write the regex as:
$str =~ s/^[ \t]*#.*\n//gm;
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |