I have a requirement to parse through a file to get a file name and a number. I would like to be able to run the script by entering scriptname.pl filename to process (ex: myscript.pl testfile.dat).
The file contents of testfile.dat look like this;
File Name|Record Count
So in this example I have 3 file names and 3 numeric value pairs. There may be only one or many similar lines in the file.
Once I have this information I need to check the contents of a second file which is located in the same directory as testfile.dat. The second file(s) will have the same file name as the one(s) extracted from step 1 except that the files have a .log extension instead of .dat.
So for the first line in the example I need to find file test_profile_affiliation_123.log
Next I need to search the contents of test_profile_affiliation_123.log until I find the string
'24 rows successfully loaded' From this string I need to capture the numeric value (24) and compare it to the numeric value from line 1, step 1.
Finally, for each file name processed I need to create a text file in the same directory as a record that the numeric values did or didn't match between step 1 and step 2. So if the first record is
And we find the matching log file;
Look for the number in the string '24 Rows successfully loaded' and compare to the numeric value from step 1.
Finally, Create file
test_profile_affiliation_123_pass.txt OR test_profile_affiliation_123_fail.txt if 24 did not exist in both files.
4) Process next file name from step 1 or end if no more.