Hi Chris, I tried to use your code, first one that reads file1 and make the hash. Does not work very well. I think it does not make hash with multiple values. Because changing the -8 +8 does not change any thing for the $lo or $hi in the second part. Probably a hash of array would work.
my %file1=(); while(<INPUT1>){ chomp; (my $id, my $number) = split("\t", $_); if ($id=~ m/(^CLS_S3_Contig[0-9]+)([-]?)([0-9]+)([_]?)([0-9] ++)$/i) { #for (my $i=$3-8; $i<=$5+8; $i++){ # print join ("\t", $1, $i), "\n"; # push (@{$file1{$1}}, $i); $file1{$1} = [$3-8, $5+8]; } } #} foreach (my($k, $v) = (sort keys %file1)){ print "$k\t$v\n"; }
Results
CLS_S3_Contig1000 CLS_S3_Contig10000 CLS_S3_Contig1000 CLS_S3_Contig10000
I should have use DATA::DUMPER Got it

In reply to Re^2: Reading two files, cmp certain cols by sesemin
in thread Reading two files, cmp certain cols by sesemin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.