What do you think of this?
use Modern::Perl q/2015/; use Number::Range; use Data::Dump qw/dump/; # First we make the range objects my $folded = Number::Range->new("655575645..827544086"); my $selfmail = Number::Range->new("827549192..827572977"); my ( @folded, @selfmail, @nomatch ); # Then we run our data through these ranges while (<DATA>) { chomp; my $int = substr( $_, 11, 9 ); do { push @folded, $_; next } if $folded->inrange($int); do { push @selfmail, $_; next } if $selfmail->inrange($int); push @nomatch, $_; } say "Folded IMB Count: ", scalar(@folded); say "No Matched IMB Count: ", scalar(@nomatch); say "Selfmail IMB Count: ", scalar(@selfmail); __DATA__ 0026110795165557564528452972062 0026110795165557648628452974959 0026110795182749420290503162401 0026110795182749566690703875348 0026110795182750564290503365856 0026110795182751155490713282618 0026110795182751819190503415474 0026110795182752054790503331977 0026110795182752888194578410931 0026110795182753115893308242647 0026110795182753522398248322033 0026110795182753601890723246006 0026110795182754156995403760702 0026110795182754174597213102232 0026110795182754408698248770395 0026110795182754919290713221614 0026110795182755128698248922635 0026110795182755566790713334451 0026110795182755669490713213633 0026110795182755806390507009696 0026110795182756204890713212248 0026110795182756217690713273839 0026110795182756259998248961157 0026110795182756309595403769515 0026110795182756708894578164887 0026110795182756829090713282238 0026110795182757082791367220156 0026110795182757130090713274108 0026110795182757297798248934527 0026110795182757370277063564556
Output
Folded IMB Count: 15 No Matched IMB Count: 1 Selfmail IMB Count: 14

The actual results are to be found in the arrays @folded, @selfmail and @nomatch. If you want to send the results to a file, just print these arrays to a file.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

In reply to Re^5: Comparing two files one with numebers and the other one with ranges range and printing matches by CountZero
in thread Comparing two files one with numebers and the other one with ranges range and printing matches by emadmahou

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.