in reply to Creating CSV term document matrix from a hash stored in multideminsional array
This:
for my $i($#classArr) {
Does not increment $i like you think it does. Essentially, it loops only once, because $#classArr is only a single number; the last element number in the array.
You want something more like:
for my $i (0..$#classArr){
Which will put the current element number into $i on each iteration, starting from 0.
update: Or, more idiomatically (untested):
for my $class (@classArr){ for my $href (@$class){ for my $key (sort keys %$href){ print $csv "$key-- $href->{$key},"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating CSV term document matrix from a hash stored in multideminsional array
by lobs (Acolyte) on Mar 03, 2017 at 20:02 UTC | |
by stevieb (Canon) on Mar 03, 2017 at 20:06 UTC | |
by lobs (Acolyte) on Mar 04, 2017 at 01:21 UTC | |
by AnomalousMonk (Archbishop) on Mar 04, 2017 at 03:03 UTC |