Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Compare 2 files and get data

by josera (Beadle)
on Sep 05, 2005 at 13:02 UTC ( #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
Node Status?
node history
Node Type: note [id://489218]
help
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2022-08-16 01:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?