http://qs321.pair.com?node_id=657058

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

Dear Monks, I am in need of a method to scan in a file formatted exactly like this:
Data Collected for SA120:Prct Dirty Cache Pages = 0 Data Collected for SA121:Prct Dirty Cache Pages = 1 Data Collected for SA122:Prct Dirty Cache Pages = 0 Data Collected for SA220:Prct Dirty Cache Pages = 0 Data Collected for SA221:Prct Dirty Cache Pages = 0 Data Collected for SA222:Prct Dirty Cache Pages = 17
and then be able to assign numerical values to variables for checking in another script. IE I'd like to be able to read in the file and then assign the numerical value after SA120 to $SA120 or some other value name. If I use something like the below, what would I need to alter in that code to get it to work? I'm not quite sure what is being done in the code below, but I think it searches for a text match with SA120, then does something else, but I'm not quite sure what as it isn't my source code.
foreach (<F_INFILE_3>) { chomp $_; $_ =~ s /^\s//g; $_ =~ s /\./_/g; if ( $_ =~ m/SA120/g ) { @TEMP_ARRAY_1 = split("=",$_); @TEMP_ARRAY_2 = split(":",$TEMP_ARRAY_1[1]); $SA120 = $TEMP_ARRAY_2[1]; }
Thanks,
-Bill