in reply to Re: Re: Comma separated list into a hash
in thread Comma separated list into a hash

Now you've done it. You do realize that I now feel compelled to figure out how this is done. :^)
  • Comment on Re: Re: Re: Comma separated list into a hash

Replies are listed 'Best First'.
Re: Re: Re: Re: Comma separated list into a hash
by BUU (Prior) on Apr 27, 2004 at 10:10 UTC
    Actually I was being overly clever and I forgot a map keyword. Whoops =/.

    Corrected: print keys map split;

    Just add three '}', three '{', one % sign and stir. =]

      I figured there had to be a map/grep in there somewhere. Being a "Bear of Very Little Brain", map (and to a lesser extent grep) still throw me.

      You'd be thinking something like:

      $s = 'hi, there, world, how, are you, today?'; print join "\n", keys %{{ map {$_ => undef} (split /,\s+/, $s)}};

      And no, I didn't figure that one out by myself :-(

      Although, I rather prefer:

      $s = 'hi, there, world, how, are you, today?'; print (join "\n", (grep ! $t{$_}++, (split /,\s+/, $s)));

      BTW. Thanks for the puzzle ;^)