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");