in reply to Extraction of set of lines using regular expression
[ The question was updated. This post is no longer relevant. ]
^ is special symbol. Escape it.
while (<>) { if ($_ =~ /\^E/gi || $_ =~ /gmake.*/gi) { push (@errors, $_) } }
which can be simplified to
while (<>) { if (/\^E|gmake/i) { push(@errors, $_); } }
It would be more reliable to only check the start of the line:
while (<>) { if (/^(?:\^E|gmake)\s*:/) { push(@errors, $_); } }
Relevant doc: perlre
|
|---|