in reply to Complex data structure

foreach my $key (sort keys %hash){ print @{$hash{$key}}[0]; #prints a1 for first hash print @{$hash{$key}}[1]; #prints b1 for first hash print @{@{$hash{$key}}[2]}[0]; #prints c2a }
See perlref. Alternatively (and I like this syntax better),
foreach my $key (sort keys %hash){ print $hash{$key}->[0]; print $hash{$key}->[1]; print $hash{$key}->[2]->[0]; }

Replies are listed 'Best First'.
Re: Re: Complex data structure
by hardburn (Abbot) on Oct 16, 2003 at 14:31 UTC

    Only that first arrow is necessary. Perl does the rest of the dereferencing without being told:

    print $hash{$key}->[2][0];

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    :(){ :|:&};:

    Note: All code is untested, unless otherwise stated