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

In reply to Yet another question about reading in data from a file for use in another file by wruehl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.