> > Looks like that question has been quite well covered.
> > Under Unix, my simple version can be reduced to:
> >
> >cat list.current | perl -ne 'print if not $seen{split'|'}++' > list.new
>
> Not so.
Had you fooled for a moment!
> First, you've got quote problems.
Doh! I'd prefer to change the outside quotes to doubles...
> Then you need to backslash the |.
I was under the impression that using single quotes on split
would protect it as a character and not a regex. However, I
am wrong and a Perl 6 RPC exists for this... it should DWIM:
http://dev.perl.org/rfc/361.html
> Then you need to turn
>
> split /\|/
>
> into
>
> (split /\|/)[3]
Opps! NB: Also lost the lc() from this too :P
> because $hash{ split ... } calls split() in scalar context, and that ain't
> no good here.
>
> perl -ne '!$seen{(split/\|/)[3]}++&&print' input > output
perl -ne '!$seen{lc~~(split/\|/)[3]}++&&print' input > output
Much nicer... obviously I broke the rule of "Test, test and test before you
post" - again. This one is tested, fortunately. Note that we need:
perl -ne '/\S/&&!$seen{lc~~(split/\|/)[3]}++&&print' input > output
to get rid of the blank line, that appeared in the example snippet.
Jonathan Paton
=====
---------------BEGIN GEEKCODE BLOCK-----------v3.12
GCS/E d+ s+: a20 C++(+++)>$ UHL++>+++ P+++ L++>++++
E- W++(-) N+ o? K- w--- !O M-- !V PS-- PE++ Y++ PGP
t@ 5-- X-- R- tv- b DI+ D- G++ e h! !r--->++ !y---
----------------END GEEKCODE BLOCK-----------------
JAPH: print`perldoc perlembed`=~/(Ju.*)/,"\n"
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]