Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Compare 2 files and get data

by josera (Beadle)
on Sep 05, 2005 at 13:02 UTC ( [id://489218]=note: print w/replies, xml ) Need Help??


in reply to Compare 2 files and get data

Hi:
Perhaps you wold have to use two while nested. In pseudocode, what i've think that you could use is:
while (<file1>){ $line1=$_ while(<file2>){ $line2=$_ foreach $field1 in $line1 foreach $field2 in $line2 if $field1 eq $field2{ print $field1 } } } } }

It compare each field in file1 with each field in file2.
If what you want is that the two fields will be in the same line, then you could use, with only one while:
while (<file1> or <file2>){ #The longest of the two files $line1=read ($file1); $line2=read ($file2); foreach $field1 in $line1 foreach $field2 in $line2 if $field1 eq $field2{ print $field1 } } } }
I hope that this pseudocode will help you
Yours sincerelly,
José Ramón Martínez

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://489218]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 06:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found