Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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?
[1nickt]: ugh, I stuck my head in the bass bin for 30 seconds on a dare at Ted Nugent at Hammersmith Odeon. Yes, I am 40% deaf now.
[johngg]: My daughter is incredibly jealous of my wife who got to see The Clash at Brixton many years ago. They went to see The Vaccines there recently.
[1nickt]: But the bands are even louder! I saw Spearhead (Michael Franti) at an outdoor show and had to walk a mile away to not feel pain in my chest! Babies were crying ... I asked the sound engineer why it was necessary to have the bass so loud and he laughed...
[Discipulus]: but the best i attended live was Mano Negra Patchanka at Forte Prenestino .. in 1990
[Corion]: Hmmm - Mano Negra or at least Manu Chao seem to put on a good live show. At least the one live CD I have from Manu Chao sounds good ;)
Discipulus feels the same jealousity of the johngg's daughter
[1nickt]: choroba I agree
[choroba]: Playing in a punk rock band for 20 years... my hearing is quite bad
[Corion]: I still have hopes to turn my godson and his two siblings into a punk band ;)

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2017-03-24 12:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (301 votes). Check out past polls.