in reply to Capture not working
'a'=~/(.)/; print("$1\n"); # a while ( 'b'=~/(.)/ ) { print("$1\n"), # b last; } print("$1\n"); # a
So don't use $1.
my $comment_re = qr{/\*.*?\*/;}s; my ($comment, $rest); while (!( ($comment, $rest) = $statement =~ m{^($comment_re)(.*)}s )) +{ defined( my $line = <$file> ) or die "Premature EOF.\n"; $statement .= $line; } print("Found type 1 comment: $comment\n");
Also fixed .* ⇒ .*?
Also fixed buggy premature EOF test.
|
|---|