in reply to one line for combining line

If you don't care about order:

$ sort -u tt.txt 123 133 3243 a b c

If you do:

$ perl -ne'$s{$_}++||print' tt.txt a b c 123 3243 133

Same, but one char shorter: (requires Perl 5.10 or higher)

$ perl -nlE'$s{$_}++||say' tt.txt a b c 123 3243 133

Replies are listed 'Best First'.
Re^2: one line for combining line
by xiaoyafeng (Deacon) on Jul 06, 2010 at 04:35 UTC

    Thanks!

    Now I know }{ and understand toolic's one line.But autovivification in your code confused me, does it mean returning FALSE when created autovivification? Any document for my reference?





    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

      Fetching a non-existent hash element returns undef. Is that what you meant? There's no autovivification. The hash elements are created when ++ assigns a value to them.

        gocha!




        I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction