in reply to Help creating/printing array of hashes
Others have directed you toward debugging (push a hashref into the array, instead of hash).
This note focuses more on perl STYLE - in particular, your use of c-style loops, which, although usable, are better written "perl style". Your loop:
could be re-coded (untested) as:for $i ( 1 .. $#allmolecules ) { ...
Note the use of "my" to localize the scope of temporary variables.for my $currentMolecule ( @allmolecules ) { ... while (my ($key,$val) = each %$currentMolecule ) { #line 222 if (ref($val) eq "ARRAY") { print "$key=@$val"; } else { print "$key=$val"; } ... } }
Syntactic sugar causes cancer of the semicolon. --Alan Perlis
|
|---|