I don't see how your problem has anything to do with map. It appears that you don't know how to return values from a sub.
is basically the same assub parsear { my $input = shift; $name = basename ( $input, @sufijos ); }
sub parsear { my $input = shift; return $name = basename ( $input, @sufijos ); }
If you want to return one of elements of the arraylist returned by fileparse, you have a few alternatives.
Temporary storage:
sub parsear { my $input = shift; my ($name, $path, $suffix) = fileparse( ... ); return $name; }
List slice:
sub parsear { my $input = shift; return ( fileparse( ... ) )[0]; }
Relying on the fact that fileparse returns the right value in scalar context:
sub parsear { my $input = shift; return scalar( fileparse( ... ) ); }
PS — Use use strict; use warnings;! Also, I wouldn't use "&" in front of sub calls. This has an effect (ignoring the prototype) you should only use when needed.
In reply to Re: Complex structures and function "map"
by ikegami
in thread Complex structures and function "map"
by nando
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |