lcanty has asked for the wisdom of the Perl Monks concerning the following question:
Afternoon fellow monks,
I've only just started learning Perl and have been a little stumped with the following,i know perl has lots of nifty shortcuts but is this possible...
I've only just started learning Perl and have been a little stumped with the following,i know perl has lots of nifty shortcuts but is this possible...
given a function, (the one i've been using is split) that returns an array is it possible to only return the first element of the array from the function and assign that to a scalar...
i.e
$bar = "some.text";
$foo = split(/\./,$bar);
now i know i could make $foo an array like @foo and access the first element of that.
But is there something i can do with the function on the right to return the first element of the array directly to $foo...
thanks
-Li
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Returning first element of an array from a function
by davido (Cardinal) on Mar 17, 2004 at 07:47 UTC | |
by biosysadmin (Deacon) on Mar 17, 2004 at 07:50 UTC | |
by Anonymous Monk on Mar 17, 2004 at 08:43 UTC | |
by Anonymous Monk on Mar 17, 2004 at 08:55 UTC | |
by Anonymous Monk on Mar 17, 2004 at 09:10 UTC | |
Re: Returning first element of an array from a function
by matija (Priest) on Mar 17, 2004 at 07:49 UTC | |
Re: Returning first element of an array from a function
by lcanty (Friar) on Mar 17, 2004 at 07:57 UTC | |
Re: Returning first element of an array from a function
by Hena (Friar) on Mar 17, 2004 at 08:18 UTC | |
by dragonchild (Archbishop) on Mar 17, 2004 at 13:13 UTC |
Back to
Seekers of Perl Wisdom