my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
I have no problem returning single elements but how would one walk this list
of elements with say a for loop?
On Sat, Jun 7, 2008 at 9:31 AM, Rodrick Brown <[EMAIL PROTECTED]> wrote:
> my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
>
> I have no problem returning single elements but how would one walk this list
> of elements with say a for loop?
>
Try this code:
use strict;
my $arrayRef = [ 1,
On Fri, Jun 6, 2008 at 9:31 PM, Rodrick Brown <[EMAIL PROTECTED]> wrote:
> my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
>
> I have no problem returning single elements but how would one walk this list
> of elements with say a for loop?
>
You can treat an array reference like an array by
Rodrick Brown wrote:
my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
I have no problem returning single elements but how would one walk this list
of elements with say a for loop?
One way:
my $level = 0;
breakdown( $arrayRef );
sub breakdown {
my $ref = shift;
Gunnar Hjalmarsson wrote:
Rodrick Brown wrote:
my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
I have no problem returning single elements but how would one walk
this list
of elements with say a for loop?
One way:
my $level = 0;
breakdown( $arrayRef );
sub breakdown {
"Rodrick Brown" schreef:
> my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
>
> I have no problem returning single elements but how would one walk
> this list of elements with say a for loop?
Start writing it differently, maybe like:
my $data = [
1,
2,
3,
[ 'a',
> "Aruna" == Aruna Goke <[EMAIL PROTECTED]> writes:
Aruna> for my $item (@$arrayRef){
Aruna> print $item unless ref($item) eq 'ARRAY';
Aruna> if(ref($item) eq 'ARRAY'){
Aruna>for my $item1(@$item){
Aruna>print $item1 unless ref($item1) eq 'ARRAY';
Aruna> {
Arun
> "(Randal" == (Randal L Schwartz) <[EMAIL PROTECTED]> writes:
(Randal> my @items = @$arrayRef;
(Randal> while (@items) {
(Randal> if (ref $items[0]) {
(Randal> if (ref $items[0] eq "ARRAY") {
(Randal> unshift @items, @{shift @items}; # replace arrayref with
co
Rodrick Brown wrote:
>
> my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
>
> I have no problem returning single elements but how would one walk this list
> of elements with say a for loop?
use strict;
use warnings;
my $arrayRef = [ 1, 2, 3, ['a', 'b', 'c', ["Hello"] ]];
my @flat = $arra