in reply to joining and sorting arrays

If you just want to find out if something's missing, you could try something like the following...
my @list1 = qw(0 1 3); my @list2 = qw(2 4 6 5); my @sortedBiglist = sort { $a <=> $b } (@list1, @list2); my @predefList = (0..$#sortedBiglist); if ("@sortedBiglist" eq "@predefList"){ print "all ok\n"; }

Replies are listed 'Best First'.
Re: Re: joining and sorting arrays
by strat (Canon) on Dec 05, 2001 at 15:59 UTC
    my @biglist = qw(0 1 3); # already saved data while (my @newList = &GetNewList() ){ @newList = sort { $a <=> $b } (@newList); unless ($bigList[-1] == $newList -1){ # Error } # unless else { my @testList = ((scalar @bigList)..($#bigList+$#newList)); # build + template list to compare unless ("@testList" eq "@newList"){ # Error } # unless else { push (@bigList, @newList); } # else } # unless } # while # -------------------------------------- sub GetNewList { return (qw(2 4 6 5)); # or whatever } # GetNewList