I am writing a Perl script which does this :
- Reads the values of the environment variables
a
toz
in a loop. Depending on the value of the environment variables, generates a result file similar to
a - 1,2,3,4 b - a,b,c c - $234.34,$123.12 keyword1 %a% keyword2 %b% keyword3 %c%
The point to note is that all the declarations have to come before the usages.
The problem is that for example I read
a
, and generate this result filea - 1,2,3,4 keyword3 %c%
Now when I read
b
, I need the result file to look like thisa - 1,2,3,4 b - a,b,c keyword1 %a% keyword2 %b%
How should I do this using Perl?
One way I can think of is to generate two different files - one with the declarations and other with the usages, and then concatenate the files at the end of execution of the script.
Is there a better way?