baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
well my problem is , that i have a file with some ranges in it . something like :
what i need is to create a file with inverse values(or to be more precise, ranges that are intact in my file). for example: (the total range is 100000000.) for values stated, the resulting ranges would be (resulting file) :39887-399900 23-900 8000-10000 50000-1000500 ... and so on ...
0-22 901-7999 10001-39886 1000501-100000000
one way to to this is with grep function, but ONLY for SMALL numbers. like:
and then retrieve first and last value in consecutive array of numbers - i now this is dumm way of doing this but nothing better is getting to me right now. so if anyone has an idea or a hint, please hint me...my @v = grep{my $x = $_; not grep{$x == $_}(100..200)}(1..1000); my @z = grep{my $x = $_; not grep{$x == $_}(170..350)}@v;
thank you !
Update:
to Corion:
ok but this does not solves the problem with overlapping regions like for 39887-50000-399900-1000500
so this algorithm(trick) solves just the half of the problem !!!that is why i was thinking of greping because that way i would remove the flanking regions
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: greping big numbers
by Corion (Patriarch) on Mar 22, 2009 at 20:42 UTC | |
by wol (Hermit) on Mar 24, 2009 at 13:03 UTC | |
Re: greping big numbers
by samtregar (Abbot) on Mar 22, 2009 at 22:25 UTC | |
Re: greping big numbers
by NetWallah (Canon) on Mar 22, 2009 at 21:20 UTC | |
Re: greping big numbers
by Perlbotics (Archbishop) on Mar 22, 2009 at 23:25 UTC | |
Re: greping big numbers
by happy.barney (Friar) on Mar 24, 2009 at 10:44 UTC |