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, 2, 3, ['a', 'b', 'c', ["Hello"] ]];

lookinto($arrayRef);

sub lookinto {
    my $obj = shift;
    if (ref $obj) {
        for (@$obj) {
            lookinto($_);
        }
    } else {
        print "$_\n";
    }
}

-- 
Jeff Peng - [EMAIL PROTECTED]
Professional Squid supports in China
http://www.ChinaSquid.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to