Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Matching elements in two arrays and printing the element next to the match.

by murugaperumal (Sexton)
on Mar 22, 2010 at 08:53 UTC ( #830046=note: print w/ replies, xml ) Need Help??


in reply to Matching elements in two arrays and printing the element next to the match.

use strict; use warnings; #this script is to match the two files and print the matched content i ++n the two files open (FILE1,"<A") or die "Can't Open $!"; my $var=<FILE1>; my @array=split(' ',$var); open (FILE2,"<B") or die "Can't Open $!"; my @new; while(<FILE2>) { chomp; push(@new, $_); } my $i; my $line; open(OUT,">nrset.txt"); foreach $line (@array) { chomp $line; for($i=0;$i<$#new;$i++) { chomp $new[$i]; if ($new[$i]=~/$line/i) { print OUT "$new[$i]\n$new[$i+1]\n"; } } }


Comment on Re: Matching elements in two arrays and printing the element next to the match.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2015-07-08 00:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls