So I have an array and a simple function that trims white spaces:
my @ar=("bla ", "ha 1")
sub trim { my $a=shift; $a =~ s/\s+$//; $a}
Now, I want to apply this to an array with the map function. Why can't I do this by just giving the function name like one would do with built in functions?
E.g. You can do
print map(length,@ar)
but you can't do
print map(trim,@ar)
you have to do something like:
print map {trim($_)} @ar
print map(trim($_),@ar)