laziness, impatience, and hubris | |
PerlMonks |
Re: Re: removal of dupes using a hashby jarich (Curate) |
on May 21, 2004 at 01:05 UTC ( [id://355143]=note: print w/replies, xml ) | Need Help?? |
The specifics in this reply are slightly less than ideal. When Perl sees you using $` and $' even once it assumes you might want to use these variables for each and every regular expression thereafter.
This is considered a bad thing because Perl will then copy the prematched text and the postmatched text into $` and $' every time it sees a regular expression. This is okay in this kind of example because the data we're dealing with appears to be small. However it rapidly becomes inefficient once we start dealing with longer strings. A similar, slightly more efficient version can be written:
It may also be worth wondering why a regular expression is needed at all:
Hope this helps, jarich
In Section
Seekers of Perl Wisdom
|
|