#!/usr/bin/perl # http://perlmonks.org/?node_id=1198153 use strict; use warnings; use Data::Dumper; my $start; my @answer; for ( sort {$a <=> $b} map tr/\n//dr, <DATA> ) { if( not defined $start or $_ > $start + 1000 ) { push @answer, [ $_ ]; $start = $_; } else { push @{ $answer[-1] }, $_; } } print Dumper \@answer; __DATA__ 141326478 103194415 86004442 86004438 86004437 86004434 86004431 85280835 85280834 85280832 53250112 50137387 50137382 50137380 29223108 25694155 17916134
In reply to Re: Stuck with manipulating an array
by tybalt89
in thread Stuck with manipulating an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |