Rats! You beat me to the punch (post?) again choroba and haukex. Your guys code-foo is strong.

UPDATE: Ah, but mine does keep his specified formatting, so I'm claiming the bonus points :-).

Well, here is my solution anyway. I'm a lot more long winded with my code than the other monks here...

#!/usr/bin/perl use warnings; use strict; @ARGV or die "No input file specified"; open my $first, '<', $ARGV[0] or die "Unable to open input file: $!"; open my $second, '<', $ARGV[1] or die "Unable to open input file: $!"; chomp(my @first_lines = <$first>); chomp(my @second_lines = <$second>); close $first; close $second; foreach (@first_lines) { my ($line_letter, $range) = split; my ($range1_low, $range1_high) = split /-/, $range; my $output_line; foreach (@second_lines) { my ($range2_low, $range2_high) = split /-/, $_; my ($current_match, $first_match); foreach my $range2_value ($range2_low..$range2_high) { last if ($range2_value > $range1_high); next if ($range2_value < $range1_low); if (($range2_value >= $range1_low) && ($range2_value <= $r +ange1_high)) { $first_match = $range2_value if (!defined $current_mat +ch); $current_match = $range2_value; } } $output_line .= "$first_match-$current_match, " if ((defined $ +current_match) && ($current_match != $first_match)); $output_line .= "$first_match, " if ((defined $first_match) && + ($current_match == $first_match)); } if(defined $output_line) { substr($output_line, length($output_line)-2, 2) = ""; print "$line_letter $output_line\n"; } }

I love it when things get difficult; after all, difficult pays the mortgage. - Dr. Keith Whites
I hate it when things get difficult, so I'll just sell my house and rent cheap instead. - perldigious

In reply to Re^2: finding intermediate range values from two file columns by perldigious
in thread finding intermediate range values from two file columns by utpalmtbi

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.