Opps type return(shift(@myarray)) -----Original Message----- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Friday, October 10, 2003 11:46 AM To: 'Jeff Westman'; 'beginners' Subject: RE: Hash Print and Delete
Why wouldn't you just return(shift(@myarray) As far as the hash why are you trying to remove it? I would assume it because you don't have a use for it outside of the scope of the subroutine. If so why don't you just make the hash scoped to the sub. Then you return the value you want and when the sub ends the hash is sent to the abyss? Not that I am some expert but that's how I would do it. Without seeing what your trying to accomplish its hard to say. Paul -----Original Message----- From: Jeff Westman [mailto:[EMAIL PROTECTED] Sent: Friday, October 10, 2003 11:40 AM To: beginners Subject: Hash Print and Delete Question: If I have an array and want to take the first element off and return it, I would do it like this: return (@myArray) ? shift(@myArray) : undef; How would I do similarly with a hash? I have something like this: return (exists $myHash{$val1} ) ? $Hash{$val2} : undef; But these leaves the value in the hash. I know I can save the value first, then DELETE it, and then return it. But I'd like to do it all in one step. TIA -Jeff __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]