Currently, I'm using a process to create a very specific set of four files. The Process I'm using is shown in the attached Process Image, below:
The first line is part of a solution, given to a previous question about Randomized Serialized Numbers.
perl -e 'for(RANGESTART..RANGESTOP){$x = $_ + 0; print "$x" . "','\n";}' > filename.csv
As you can see, RANGESTART is generally something like 30000000 RANGESTOP would generally be something like 30010000, giving me 10,000 numbers, counting up from 30,000,000.
For the purpose of validation (Regulator Body Requirement), I have to perform a check, to make sure the numbers generated are unique and never duplicated. This validation must create a secondary file (filename-sort.csv). To accomplish this, I'm using:
sort -u -o filename1.csv filename2.csv
At this point I have two files.
I have to use a 3rd Party Application (Seagull Scientific's Bartender), for the purpose of printing labels, on a production line. One side of the line needs a file with only even numbers, the other side needs a file with only odd numbers. To accomplish this, I'm using:
awk '{print>sprintf("%sfile.csv",NR%2?"even":"odd",PROCINFO["pid"])}' filename.csv
Now I have my four files.
These four files are a requirement, to appease a potential audit, by a Regulatory Body.
This process works fine, but requires my direct involvement, every time a new number set is needed.
My question has two parts:
Part A: I'd like to do this all with three individual perl commands, much the same way I'm already doing this with perl, sort and awk.
Part B: I'd like to be able to combine those three perl commands, into a single perl script, leaving the three perl commands from Part A, in-tact in their original form.
I imagine this perl script would ask a user for a starting number, an ending number and 8-digit date (YYYYMMDD). As the script completes, it should ask for the user's input to confirm the creation of the first file (YYYYMMDD.csv), confirm creation of the sorted file (YYYYMMDD-sort.csv) and confirm creation of even/odd files (evenfile.csv & oddfile.csv).
I imagine the file creation prompts working something like this:
- Enter "Y" or "YES" to create YYYYMMDD.csv (Any other answer should exit the script).
- Enter "Y" or "YES" to create YYYYMMDD-sort.csv (Any other answer should exit the script).
- Enter "Y" or "YES" to create evenfile.csv and oddfile.csv (Any other answer should exit the script).
Finally, I'd like this perl script to be able to run from Apple's Terminal, Linux Terminal and Windows 7 Pro CMD Line.
Am I asking too much? If so why? If not, how?