goingcrazy has asked for the wisdom of the Perl Monks concerning the following question:
This script just runs creating a nrset.txt file which is empty but doesn't show any matches. While I supposed my File having ids with sequence is too huge, tried to take few checkfiles which gave expected results as my script should do. Help me fellas!#! usr/bin/perl #this script is to match the two files and print the matched content i +n the two files $p="FILEA"; open (FILE1,$p); @array =<FILE1>; #print "@array"; $p1="FILEB"; open (FILE2,$p1); @new = <FILE2>; #print "@new"; foreach $line (@array) { chomp $line; open (OUT,">nrset.txt"); for($i=0;$i<@new;$i++) { chomp $new[$i]; # print "$new[$i]\n"; if ($new[$i] =~ /$line/i) { $pos = $i; print "$pos\n"; print OUT "$new[$i]\n$new[$i+1]\n"; # print "$new[$i]\n$new[$i+1]\n"; } }}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching elements in two arrays and printing the element next to the match.
by Corion (Patriarch) on Mar 22, 2010 at 08:49 UTC | |
by 7stud (Deacon) on Mar 22, 2010 at 11:52 UTC | |
by Anonymous Monk on Mar 23, 2010 at 05:15 UTC | |
|
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 | |
|
Re: Matching elements in two arrays and printing the element next to the match.
by spazm (Monk) on Mar 22, 2010 at 15:34 UTC | |
|
Re: Matching elements in two arrays and printing the element next to the match.
by grizzley (Chaplain) on Mar 22, 2010 at 08:51 UTC | |
|
Re: Matching elements in two arrays and printing the element next to the match.
by thillai_selvan (Initiate) on Mar 22, 2010 at 08:53 UTC |