PetreAdi has asked for the wisdom of the Perl Monks concerning the following question:
I have a huge array (90 000 elements) and I want to create a lot of other arrays
Now for some quick example:
my @unique = (1, 20, 3, 4, 44, 55, 66, 77, 5, 10, 2, 11, 20, 42, 30, 3 +1, 32, 33, 34, 35, 36, 37, 40); my @in = (4, 3, 2, 2, 42, 40); my %first_index = map { $unique[$_] => $_ } reverse 0 .. @unique-1; my @idxs = map { $first_index{$_} // -1 } @in; @idxs = sort { $a <=> $b } @idxs;; $first = @idxs[0]; $cont = 1; for (1 .. $#idxs) { $diff = @idxs[$_] - $first ; if (($diff > 5) && ($diff < 10)) { @temp = @unique[$first+1..@idxs[$_]-1]; print join(", ", @temp); $diff = $diff-1; print " Hit $cont Length $diff \n"; $cont += 1; } $first = @idxs[$_]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Better way to do this
by hdb (Monsignor) on Feb 20, 2016 at 18:05 UTC | |
by PetreAdi (Sexton) on Feb 20, 2016 at 18:51 UTC | |
|
Re: Better way to do this
by BrowserUk (Patriarch) on Feb 20, 2016 at 19:12 UTC | |
by PetreAdi (Sexton) on Feb 20, 2016 at 19:49 UTC | |
by BrowserUk (Patriarch) on Feb 20, 2016 at 22:02 UTC | |
by PetreAdi (Sexton) on Feb 20, 2016 at 22:52 UTC | |
by Laurent_R (Canon) on Feb 20, 2016 at 23:42 UTC | |
by Laurent_R (Canon) on Feb 20, 2016 at 23:54 UTC | |
|
Re: Better way to do this
by Cristoforo (Curate) on Feb 21, 2016 at 00:58 UTC | |
|
Re: Better way to do this
by BillKSmith (Monsignor) on Feb 22, 2016 at 20:38 UTC |