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:
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.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
Thanks,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]; }
-Bill
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Yet another question about reading in data from a file for use in another file
by RaduH (Scribe) on Dec 14, 2007 at 16:02 UTC | |
by wruehl (Acolyte) on Dec 14, 2007 at 18:25 UTC | |
Re: Yet another question about reading in data from a file for use in another file
by davies (Prior) on Dec 14, 2007 at 16:03 UTC | |
Re: Yet another question about reading in data from a file for use in another file
by caelifer (Scribe) on Dec 14, 2007 at 16:23 UTC | |
Re: Yet another question about reading in data from a file for use in another file
by poolpi (Hermit) on Dec 15, 2007 at 16:05 UTC |
Back to
Seekers of Perl Wisdom