in reply to formatting substitute and arrays

It would really help if you could post some of the code that you currently have, so that we can see what you've tried so far. For the first part of your question, you might want to try using sprintf, something like this:
my $new_value = sprintf("%.5f", $unformatted_value); s/old_value/$new_value/;
I didn't really understand what you're trying to do, so I'm sorry I can't be of much more help.