Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Reading in two text files

by stevieb (Monsignor)
on Apr 24, 2012 at 21:55 UTC ( #966948=note: print w/replies, xml ) Need Help??


in reply to Reading in two text files

I'm not trying to be sarcastic or ignorant, but to get effective feedback from the PerlMonks community, please peruse this link.

I've quickly reformatted your post within <P> and <code> tags so that it is easier read:

OP:

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 = $BRead1; $buseddsk = $BRead2; $bfreedsk = $BRead3; } while (<secondfile>) { chomp; @elines=grep(/dev/, $_); foreach $eline (@elines) { @ERead = split(" ", $eline); $emount = $ERead[0]; $etotdsk = $ERead1; $euseddsk = $ERead2; $efreedsk = $ERead3; } 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.

/OP

Replies are listed 'Best First'.
Re^2: Reading in two text files
by stevieb (Monsignor) on Apr 24, 2012 at 22:12 UTC

    Provide (within <code> </code> tags) some of your input, and let us know what you would like the result to be. To me, the word 'sync' can mean a few things. An example of what you have to work with and an example of what you expect would be beneficial.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://966948]
help
Chatterbox?
[Corion]: Meh. I get the feeling I should post a call-to-action for people to test their modules with the upcoming 5.26 (or 5.25.latest), as it seems that the smoke testers don't really weed out modules that fail without . in @INC
[Corion]: But without instructions on how to easily test things yourself, I don't think such a call to arms is helpful
[Corion]: (this post on nntp.perl.org / p5p makes it seem to me that smoke testers seem to have a blind spot there)
[Corion]: Hmmm. Maybe setting $ENV{PERL5LIB}=" some path without dot"; perl Makefile.PL; make test already is enough to locally test your module...
[Corion]: Meh, no, will need a BEGIN hook...
[Corion]: ... and PERL5OPT does not like -e in it :-(

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-03-27 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (317 votes). Check out past polls.