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

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. =]
  • Comment on Re: Re: Re: Re: Comma separated list into a hash

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Comma separated list into a hash
by gsiems (Deacon) on Apr 27, 2004 at 17:17 UTC

    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 ;^)