Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl program that changes certain values in an input deck and runs an executable, opens the output file, finds the important number and stores it in an array.

I have two questions:

I looked through the previous submissions, and I could not find a similar type question. I apologize if it has already been addressed.

Replies are listed 'Best First'.
Re: formatting substitute and arrays
by thelenm (Vicar) on Apr 26, 2002 at 22:09 UTC
    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.
Re: formatting substitute and arrays
by asdfgroup (Beadle) on Apr 26, 2002 at 22:30 UTC
    1) try  s/old_value/sprintf("%.5f", new_value)/e;

    2) should work something like :

     print PLOT (map {sprintf "%.5f", $_} @a), "\n" or  print PLOT (sprintf "%.5f"x@a, @a), "\n"