http://qs321.pair.com?node_id=123619


in reply to Finding missing elements in a sequence (code)

Huh? How do you call it? This runs fine on my machine:

sub find_holes { my @list = @{ shift() }; @list = sort { $a <=> $b } @list; my $low = $list[0]; my $high = $list[-1]; my %isthere = map { $_ => 0 } ($low..$high); $isthere{$_} = "yes" for @list; my @vacancies = grep { not $isthere{$_} } sort keys %isthere; return \@vacancies; } print "@{find_holes([qw(0 1 2 3 4 6 8)])}\n";

Prints:

d:\tmp\try>perl try.pl perl try.pl 5 7 d:\tmp\try>

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com