in reply to Referencing an array in a complex hashed data structure
So ... I am lost the forest of braces and brackets...
Then for goodness sake, use some horizontal whitespace!. Ie. spaces.
The only place you've used any is between the function name join, and its open paren where is is completely useless as the paren forms a natural delimiter!
The same snippet with some added makes it easy to see the problems:
sub reportWA{ # $key my $key = shift; my $NewWA; unshift @{ WA{ $key }{ stags } }, $WA{$key}{PT}; unshift @{ $WA{ $key }{ stags } }, $WA{$key}{PT}; $NewWA = $WA{ $key }{ PT }; $#{ @{ WA{ $key }{ stags } } } = $rnds-1; for my $i ( 1 .. $rnds -1 ){ ${ WA{ $key }{ stags } }[ $i ] *= $wght; $NewWA += ${ WA{ $key }{ stags } }[ $i ]; } #plog sprintf "stages = %s" ,join (", ",@stags); $NewWA /= $rnds; printf " %d %d %8.2f %s\n" , $key, $WA{ $key }{ PE }, $NewWA, join( ", ", @{ WA{ $key }{ stags } } ); }
The same with the errors highlighted:
sub reportWA{ # $key my $key = shift; my $NewWA; unshift @{ $WA{ $key }{ stags } }, $WA{$key}{PT}; #............^ $NewWA = $WA{ $key }{ PT }; $#{ @{ WA{ $key }{ stags } } } = $rnds-1; #........^ ......missing $ for my $i (1..$rnds-1){ ${ WA{ $key }{ stags } }[ $i ] *= $wght; #......^...missing $ $NewWA += ${ WA{ $key }{ stags } }[ $i ]; #................^..........missing $ } #plog sprintf "stages = %s" ,join (", ",@stags); $NewWA /= $rnds; printf " %d %d %8.2f %s\n" , $key, $WA{ $key }{ PE }, $NewWA, join( ", ", @{ WA{ $key }{ stags } } ); #.............................^......missing $ }
There may be more errors, but once you fixed those, there'll be less noise from the compiler that should allow you to see what's going on.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Referencing an array in a complex hashed data structure
by Wiggins (Hermit) on Dec 08, 2008 at 20:17 UTC |