Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: See if arrays match

by redsquirrel (Hermit)
on Jul 24, 2002 at 01:28 UTC ( [id://184658]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://184658]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-29 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found