Seamus Abshere wrote:
dear Perl experts,
my @array;
$array[0] = split(' ','apples trucks');
$array[1] = split(' ','cars oranges');
i want to get "apples" from
print $array[0][0]
or
print $array[0]->[0]
but they don't work.
If you had had warnings enabled then perl would have warned you about doing
that:
$ perl -le'use warnings; $_ = split " ", "one two three"; print'
Use of implicit split to @_ is deprecated at -e line 1.
3
What you need to do is store the list returned from split() to an anonymous
array and then assign the reference of that array to the scalar:
my @array;
$array[0] = [ split(' ','apples trucks') ];
$array[1] = [ split(' ','cars oranges') ];
if i do
print $array[0]
i get "2", the size of the array.
i thought $array[0] was a scalar reference to an anonymous array and
that this meant
$array[0][0]
would "dereference" to "apples". but no luck.
thanks for any pointers! (ouch)
perldoc perldata
perldoc perldsc
perldoc perllol
perldoc perlreftut
perldoc perlref
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>