How would I iterate through the array $thing{list}? ie, what would I write for a foreach loop?
my %thing = ( name => 'fred', count => 100, list => [ 1..10 ] ); print $thing{ list }[ 3 ]; 4 for my $item ( @{ $thing{ list } } ) { print $item; } 1 2 3 4 5 6 7 8 9 10 for( my $index=0; $index < @{ $thing{ list } }; ++$index ) { print "$index : $thing{ list }[ $index ]"; } 0 : 1 1 : 2 2 : 3 3 : 4 4 : 5 5 : 6 6 : 7 7 : 8 8 : 9 9 : 10 print for @{ $thing{ list } }; 1 2 3 4 5 6 7 8 9 10
In reply to Re^4: C-Style Struct?
by BrowserUk
in thread C-Style Struct?
by Mr. Newb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |