in reply to Re: array and hash
in thread array and hash
You could store the results in a hash rather than array, if inputs are all unique strings:
You could make the results array contain hash-based records instead of array-based:my %results; for ( @array ) { $results{$_} = some_func($_); }
Etc. There's also shortcuts for the loop:my @results; for ( @array ) { push @results, { input => $_, output => some_func($_) }; }
my %results = map { ( $_ => some_func($_) ) } @array;
Etc.my @results = map { { input => $_, output => some_func($_) } } @array;
|
|---|