There's more than one way to do things | |
PerlMonks |
Re^2: make a search pattern and remove duplicate from the fileby jimpudar (Pilgrim) |
on May 11, 2018 at 16:15 UTC ( [id://1214390]=note: print w/replies, xml ) | Need Help?? |
I think what he is asking for is to print out only the first instance of any line which has a unique value of the pet, hate tuple. Any other lines should be ignored. Since the structure you are building does not keep track of which line came first, looping over it will never bring you to the answer he is looking for. If you really wanted to do this with a one liner, (and I'm definitely not saying you should), I would do this, which will print exactly the result he asked for:
Best, Jim
In Section
Seekers of Perl Wisdom
|
|