in reply to (Golf) unique

01 23456789012345678 perl -ne '$_{$_}++ or print' < infile > outfile
That's 18.

_________
broquaint

Replies are listed 'Best First'.
Re: Re: (Golf) unique
by insensate (Hermit) on Apr 24, 2003 at 16:14 UTC
    In the same manner even:
    01 234567890123 perl -ne "$$_++||print" < infile > outfile

      Very nice. ++

      But it will fail if the infile looked like this: ;-)

      $ cat infile here comes trouble 1 2

      --
      John.

        Have you tried your input? It works fine for me. As $_ isn't chomp()'d, it escapes the problem of modifying a readonly $1.

        -sauoq
        "My two cents aren't worth a dime.";
        

      Here's a version which shouldn't rely on 5.8:

      01 2345678901234567 perl -ne '${_.$_}++||print'

      -sauoq
      "My two cents aren't worth a dime.";