> is a greedy match
That's not the accurate term, it's just a multiple match and you only want the last one.°
One way to achieve this in a one-liner is not to print all the matches but to store them in an array and to only print the last match in an END{} block.
The difficulty here is to always reset the array for previous matches.
> Note this is extremely large file and can't put the whole file into a string.
In this case it might be better to go reverse and read a sliding window from the end.
But I don't know how to do this with a one-liner.
To decide this one needs to know how "large" is "extreme" ?
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
°) I think I misunderstood your problem, see Re: command line perl command to get between lines with non greedy match for another approach.
In reply to Re: command line perl command to get between lines with non greedy match
by LanX
in thread command line perl command to get between lines with non greedy match
by ravi_perl_monks
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |