Subject: | comment regexps at end-of-string |
Date: | Sun, 09 Jul 2017 16:39:41 +1000 |
To: | bug-Regexp-Common [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
As an idea for a feature in Regexp::Common::comment, it could be good to
have an option allowing match of comment start through to end-of-string,
in addition to the expected end delimiter.
For example perl is happy to run code where the last line of a file is
comment with no final newline, but Regexp::Common doesn't match that,
use Regexp::Common 'comment';
print "# blah" =~ $RE{'comment'}{'Perl'};
=>
false
For crunching a slurped file, matching like execution would ensure a
final comment isn't crunched as code when it should be comment.
Languages with specific ending comments like /* ... */ usually don't
like a missing terminator, but again if crunching a slurped file it
could be reasonable to be more relaxed. Maybe the -keep vars could come
out as empty string for no end, if an application wanted to know this
happened.
Either way for compatibility I imagine this could be only an option.