in reply to Re: Sorting an Array
in thread Sorting an Array
Not sure I understand the last comment about using my %entry. I'm sure this may help in speed of script. So I would love some further clarification on that.
This refers to the for loop where you're pushing entries onto your @statement array. You're explicitely constructing a named hash, %entry, each time, but this isn't necessary; you can just as well do this:
for (@{ $data->{'mail-item'} }) { push @statements, { job => $_->{'mail-jobnum'}, product => $_->{'mail-prodnum'}, statement_data => $_->{'mail-statement-date'} }; }
Or, since you only have one statement in your loop body now, you can even use for as a statement modifier:
push @statements, { job => $_->{'mail-jobnum'}, product => $_->{'mail-prodnum'}, statement_data => $_->{'mail-statement-date'} } for (@{ $data->{'mail-item'} });
Although I personally consider this less readable than the "regular" loop above.
|
|---|