Since nobody mentioned it, the problem is that the return value of s/// isn't the modified string.
my @points = map { s/\s+//; $_ } split(/\t/, $_);
But then you're modifying map's arguments without intending to do so. Modifying $_ in map is a bad idea. (If you really do mean to modify map's arguments, using for would make your intent more obvious.)
my @points = map { local $_ = $_; s/\s+//; $_ } split(/\t/, $_);
Yuck! List::MoreUtils provides a function for just this purpose. It even uses a better method of localizing $_.
use List::MoreUtils qw( apply ); my @points = apply { s/\s+// } split(/\t/, $_);
In reply to Re: Splitting on tabs then removing extra white space with map
by ikegami
in thread Splitting on tabs then removing extra white space with map
by c4onastick
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |