in reply to Complex structures and function "map"
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Complex structures and function "map"
by nando (Acolyte) on Oct 21, 2011 at 18:40 UTC | |
by ikegami (Patriarch) on Oct 21, 2011 at 19:20 UTC | |
by nando (Acolyte) on Oct 21, 2011 at 20:48 UTC | |
by ikegami (Patriarch) on Oct 23, 2011 at 10:56 UTC |