ramthen has asked for the wisdom of the Perl Monks concerning the following question:
Hello All,
Would like to know what is wrong with the code (below) that I wrote to extract group of lines that match a set of patterns (including the lines that match the pattern)
code is here:
if ($_ =~ /^E/gi || $_ =~ /gmake.*/gi) { push (@errors, $_) }
and the lines from which I need to extract text is here:
I have updated since the lines do not start with that special character (carat) at the line beginning (as posted intially)
E : abcdfcsds 1387382 43243 ijigje jg445 3u4 (53545545) E : abcdfcsds 1387382 43243 ijigje jg445 3u4 (53545545) E : abcdfcsds 1387382 43243 ijigje jg445 3u4 (53545545) E : abcdfcsds 1387382 43243 ijigje jg445 3u4 (53545545) E : abcdfcsds 1387382 43243 ijigje jg445 3u4 (53545545) gmake : **** build failed fdjgu43uffer Error 1
With this code, am able to extract the last line only (i.e. the one starts with ^E).
Could anyone tell me what is wrong with regular expression ?
thanks in advance
/Ram
Edited by planetscape - swapped out some p tags for some code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extraction of set of lines using regular expression
by ikegami (Patriarch) on Apr 28, 2006 at 19:47 UTC | |
|
Re: Extraction of set of lines using regular expression
by TedPride (Priest) on Apr 28, 2006 at 20:09 UTC | |
|
Re: Extraction of set of lines using regular expression
by ikegami (Patriarch) on Apr 28, 2006 at 19:28 UTC | |
|
Re: Extraction of set of lines using regular expression
by eff_i_g (Curate) on Apr 28, 2006 at 19:56 UTC |