in reply to use of uninitialized value in array
Chris#!/usr/bin/perl use 5.010; use strict; use warnings; my $gene_list = 'gene_list.txt'; open GL, "<", $gene_list or die "Unable to open $gene_list because $!" +; my %seen; while (my $gene = <GL>) { $seen{$gene}++; } close GL or die "Unable to close $gene_list because $!"; my $hfr = 'HFR_genes.txt'; open HFR, "<", $hfr or die "Unable to open $hfr because $!"; while (my $gene = <HFR>) { print if $seen{$gene}; } close HFR or die "Unable to close $hfr because $!";
Update: If both files have unique lines, the code could be shortened to:
With the command line supplying the 2 files: perl your_program.pl gene_list.txt HFR_genes.txtmy %seen; print grep $seen{$_}++, <>;
|
|---|