hennesse has asked for the wisdom of the Perl Monks concerning the following question:
hardCodedPrint() needs help. What I need is something like for ( $i=0; $i <= $# $thirdList{$area}; $i++ ) { But no matter what kind of casts and !@#$%^&* stuff I put in there (like $# @{ $thirdList{$area} }, I get a "$# is no longer supported" type of error - or worse. Any ideas? Thanks - Daveuse strict; use warnings; my $itemArea; my $itemPrice; my $itemId; my %thirdList; my $area; my $i; $itemArea = "0188"; $itemId = "0000007777"; $itemPrice = "40"; push @{ $thirdList{$itemArea} }, [ $itemArea, $itemId, $itemPrice ]; $itemArea = "0188"; $itemId = "0000009980"; $itemPrice = "41"; push @{ $thirdList{$itemArea} }, [ $itemArea, $itemId, $itemPrice ]; $itemArea = "0123"; $itemId = "0000008888"; $itemPrice = "50"; push @{ $thirdList{$itemArea} }, [ $itemArea, $itemId, $itemPrice ]; $itemArea = "0123"; $itemId = "0000009999"; $itemPrice = "51"; push @{ $thirdList{$itemArea} }, [ $itemArea, $itemId, $itemPrice ]; hardCodedPrint(%thirdList); sub hardCodedPrint { foreach $area ( keys %thirdList) { for ( $i=0; $i <= 1; $i++ ) { print "THIRD: "; print $thirdList{$area}[$i][0], " - "; print $thirdList{$area}[$i][1], " - "; print $thirdList{$area}[$i][2], "\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl 5.12.2 Data Structures
by stevieb (Canon) on Sep 22, 2016 at 23:53 UTC | |
by AnomalousMonk (Archbishop) on Sep 23, 2016 at 05:20 UTC | |
|
Re: Perl 5.12.2 Data Structures
by AnomalousMonk (Archbishop) on Sep 23, 2016 at 05:37 UTC | |
|
Re: Perl 5.12.2 Data Structures
by tybalt89 (Monsignor) on Sep 22, 2016 at 23:56 UTC | |
|
Re: Perl 5.12.2 Data Structures
by Anonymous Monk on Sep 23, 2016 at 00:17 UTC | |
|
Re: Perl 5.12.2 Data Structures
by hennesse (Beadle) on Sep 23, 2016 at 01:22 UTC | |
by haukex (Archbishop) on Sep 23, 2016 at 08:03 UTC |