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