Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I am new to Perl and have a question about handling the output for reading and writing two separate files. I am reading in Unix/AIX/Linux dflog files and them performing calculations on the space utilization of the individual file systems. The section of my code reads as follows:
open( firstfile, "DFLOG1.txt"); open( secondfile, "DFLOG2.txt"); while (<firstfile>) { chomp; @blines=grep(/dev/, $_); foreach $bline (@blines) { @BRead = split(" ", $bline); $bmount = $BRead[0]; $btotdsk = $BRead[1]; $buseddsk = $BRead[2]; $bfreedsk = $BRead[3]; } while (<secondfile>) { chomp; @elines=grep(/dev/, $_); foreach $eline (@elines) { @ERead = split(" ", $eline); $emount = $ERead[0]; $etotdsk = $ERead[1]; $euseddsk = $ERead[2]; $efreedsk = $ERead[3]; } print (OUTFILE " ,$bmount, $btotdsk, $busedsk, $bfreedsk, $etotdsk, $e +useddsk, $efreedsk\n");
Where I am having difficulty is getting the lines of the two files to sync. Depending on where I place my print statement I either get the last filesystem entry from the first file being compared to all the filesystems in the second or vice verse. Any insight as to how to correct my issue is greatly appreciated.

In reply to Reading in two text files by Spartan4ever

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [choroba]: erix :-D

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (9)
    As of 2018-05-22 16:23 GMT
    Find Nodes?
      Voting Booth?