Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Compare 2 files and get data

by reneeb (Chaplain)
on Sep 05, 2005 at 08:41 UTC ( [id://489169]=note: print w/replies, xml ) Need Help??


in reply to Compare 2 files and get data

One way to do it is using Tie::File:
#!/usr/bin/perl use strict; use warnings; use Tie::File; my $file1 = '/path/to/file.txt'; my $file2 = '/path/to/file2.txt'; tie my @lines1,'Tie::File',$file1 or die $!; tie my @lines2,'Tie::File',$file2 or die $!; my @both = grep{my $i = $_; grep{$_ =~ $i}map{(split(/,/,$_))[1]}@line +s2}map{(split(/,/,$_))[0]}@lines1; untie @lines2; untie @lines1; print $_,"\n" for(@both);
It's untested...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found