in reply to Re^2: Comparing two files one with numebers and the other one with ranges range and printing matches
in thread Comparing two files one with numebers and the other one with ranges range and printing matches

I'm quite sure it is possible, but you will first have to explain the rules how to differentiate between these three categories.

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
  • Comment on Re^3: Comparing two files one with numebers and the other one with ranges range and printing matches

Replies are listed 'Best First'.
Re^4: Comparing two files one with numebers and the other one with ranges range and printing matches
by emadmahou (Acolyte) on Jun 16, 2015 at 13:50 UTC
    I have two files the first one is a range
  • imb,folded ,655575645,827544086
  • imb,selfmail ,827549192,827572977
  • the second one is a list of number I am looking for position 11 for 9 and then compare if there is match with the range
  • 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
  • right now mu out put looks like this
  • folded IMB Count: 15
  • No Matched IMB Count: 1
  • selfmail IMB Count: 14
  • my code is getting the version from the hash, now I am trying to create a three files that contains the original number from the list file with the version name in this case will be three
      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