Dageek
#!/usr/bin/perl -w use strict; my @list = ( 1,4,3, 2, 5, 6); my $index=0; ## set to the number your list should start at my $list_start=1; @list = sort {$a<=>$b} @list; my $msg = "list is ok\n"; for (@list) { if ($list[$index] != $index + $list_start) { $msg="bad list\n"; last; } $index++; } print "$msg";
In reply to Re: Validate array of numbers in sequence
by johndageek
in thread Validate array of numbers in sequence
by AcidHawk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |