in reply to Storing Regex Results
like this you save all the lines that matche your regexp and can work of them. but if you want to save the match result, then:my @array; while ($line = <DATA>) { if ($line =~ /regexp/) { push(@array, $line); } }
my @array; while ($line = <DATA>) { if ($line =~ /(regexp)/) { # surrounding the regexp with brackets push(@array, $1); # holds the result of the match from the last +regexp } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Storing Regex Results
by johnirl (Monk) on Aug 20, 2002 at 09:25 UTC |