in reply to Re: Re: (Golf) unique
in thread (Golf) unique


Very nice. ++

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

$ cat infile here comes trouble 1 2

--
John.

Replies are listed 'Best First'.
Re: Re: Re: Re: (Golf) unique
by sauoq (Abbot) on Jun 04, 2003 at 07:50 UTC

    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.";
    

      Have you tried your input?

      Yes I tried the input.

      I test everything before I post it here. I have a test directory full of files called file, file1, file2, numfile, bigfile, blankfile, etc.

      Nevertheless, it is difficult to test for every eventuality. It looks like the behaviour changes between 5.6 and 5.8:

      $ perl5.005_03 -ne '$$_++||print' infile here comes trouble Modification of a read-only value attempted at -e line 1, <> chunk + 4. $ perl5.6.1 -ne '$$_++||print' infile here comes trouble Modification of a read-only value attempted at -e line 1, <> chunk + 4. $ perl5.8.0 -ne '$$_++||print' infile here comes trouble 1 2

      --
      John.

        Yes I tried the input.

        Good. I thought you would have. I've learned to expect you to be rigorous. That's why I asked; I was surprised when it worked for me. I guess I should have known it was a version thing... now it all makes sense. :-) I'll update "my" solution, which really isn't "mine" at all, to reflect that.

        Thanks, John.

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