Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!pyrltd!pyra.co.uk!jimmy From: jimmy@pyra.co.uk (Jimmy Aitken) Newsgroups: comp.lang.perl Subject: Removing associative array entries Message-ID: <671199580.AA19806@flaccid> Date: 9 Apr 91 12:19:41 GMT Sender: news@pyra.co.uk (News system) Reply-To: jimmy@pyra.co.uk (Jimmy Aitken) Organization: Pyramid Technology Ltd, Farnborough, ENGLAND Lines: 39 I have a list of stuff in an associative array, and as I process each elemnt, I want to undefine it. When I finish processing the array via a key look up, the element is removed. This is done so that I have the remaining entries left which need to be handled specially. i.e. while(<>) { last if /^end/; $ARRAY{$_}=1; } while(<>) { ($f1,$f2,$f3)=split(/"/,$_); if (defined($ARRAY{$f2})) { process it; undef $ARRAY{$f2}; } } while(($key,$value)=each%ARRAY) { process $value; } In the case above, the entry in the array ($value) is undefined, but the name of the element is still there. Is there any way to remove the name of the element sso it wont appear in the $key variable in the above example? I can get around the problem, by doing a 'prcoess $key if defined($value)', but I was wondering if there was a 'cleaner' way. Thanks, Jimmy -- jimmy@pyra.co.uk -m------- Jimmy Aitken jimmy@pyramid.pyramid.com ---mmm----- Pyramid Technology Ltd ..!mcsun!ukc!pyrltd!jimmy -----mmmmm--- Pyramid House, Solartron Rd (+44) 252 373035 -------mmmmmmm- Hants GU14 7PL, ENGLAND - Managing software engineers is like herding cats