in reply to array and hash

You can accomplish something like what (I think) you're asking using a hash, so long as your array will not contain duplicates.
my %hash; $hash{$_} = some_output($_) for @array; # Print each in arbitrary order like so: print $hash{$_} for keys %hash; # Print in original sequence by reusing the array: print $hash{$_} for @array; sub some_output { local $_; # Insert mystery code here }
Update: Fixed mundane detail.