in reply to Re: See if arrays match
in thread See if arrays match

Your code returns the following when run with warnings enabled: Use of uninitialized value in string eq at... Here's one way to do avoid the warning:
while ((my $this = shift @sorted) and @sorted) ...
The warning occurs on the last iteration after you have shifted out the last element of @sorted.

--Dave

Replies are listed 'Best First'.
Re: See if arrays match
by flocto (Pilgrim) on Jul 24, 2002 at 09:46 UTC

    Oops, you're right.. I was in the unlucky position that the last element of my test array was a duplicate. In this case there wouldn't appear an error.. However, I think it's easier (to understand, anyway) to just change the condition for the first while to:

    while (@sorted > 1) ...

    Which works, because if there is only one element left, it can't be a duplicate.

    Thanks for pointing this out :)

    Regards,
    -octo