[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] map {} one-liner that removes trailing spaces



(I'm still not a daily map user, but maybe I'm getting there?)

perldoc -f map


Answer:
---------
map { s/\s+$// } @j;


Demo code:
---------
$ cat j.pl
my @j = ("a  ", "b  ", "c  ");
print join "|", @j;
print "\n";

map { s/\s+$// } @j;

print join "|", @j;
print "\n";


Demo run:
---------
$ perl j.pl
a  |b  |c
a|b|c


Cheers,

j