in reply to map and grep one-liner problem
return (map{ /^$key/ and s/^$key//, $_ } grep( /^$key/, @ta))[1] ;
Are you sure you want the comma operator inside the map? Try
map{ /^$key/ and s/^$key//; $_ } grep( /^$key/, @ta)
The s/// inside the map evaluates to 1.
What I don't understand too is that when I replace the map expression withit doesn't work verywell anymore, I only added a print statement ?map{ /^$key/ and s/^$key// and print "val=$_\n", $_ }
Same here. print "val=$_\n", $_ prints $_ twice, and map does return 1 (the result of print, if successful).
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|