Re: delete vs undef

2004-07-09 Thread Gunnar Hjalmarsson
Philipp Traeder wrote: Gunnar Hjalmarsson wrote: Your wording "if a hash contains an element" is ambigous IMO. A hash or associative array consists of key/value pairs, where the keys are indexes and the values are considered to be the elements (I think). Ok - that's a possible terminology, and yes,

Re: delete vs undef

2004-07-09 Thread Christopher J. Bottaro
perl.org wrote: > Wait a second...I always thought undef was a constant value. Is it always > a > function or are there both? I don't know that it matters but I prefer to > show the parens when I invoke a function, but everywhere in my code I have > $var = undef; its a function. it always retur

Re: delete vs undef

2004-07-09 Thread Christopher J. Bottaro
ahh great, you all cleared it up perfectly for me, thank you. that perlfaq section was great also. Philipp Traeder wrote: > On Friday 09 July 2004 19:25, Gunnar Hjalmarsson wrote: >> Philipp Traeder wrote: >> > I don't know what an expert would say, >> >> Neither do I. :) > > I think this is a

Re: delete vs undef

2004-07-09 Thread John W . Krahn
On Friday 09 July 2004 08:14, Christopher J. Bottaro wrote: > > i want to remove items from a hash then later see if they exist using > defined(). for example: > > delete($hash{MYKEY}); > # blah blah > if (defined($hash{MYKEY})) { > # do blah blah > } > > which should i use? delete()

Re: delete vs undef

2004-07-09 Thread Philipp Traeder
On Friday 09 July 2004 19:25, Gunnar Hjalmarsson wrote: > Philipp Traeder wrote: > > I don't know what an expert would say, > > Neither do I. :) I think this is a good base for talking about hashes. ;-) > > but for testing if a hash contains an element, I normally use > > "exists": > > Your wordi

Re: delete vs undef

2004-07-09 Thread Gunnar Hjalmarsson
Philipp Traeder wrote: I don't know what an expert would say, Neither do I. :) but for testing if a hash contains an element, I normally use "exists": Your wording "if a hash contains an element" is ambigous IMO. A hash or associative array consists of key/value pairs, where the keys are indexes an

Re: delete vs undef

2004-07-09 Thread Philipp Traeder
On Friday 09 July 2004 17:14, Christopher J. Bottaro wrote: > i want to remove items from a hash then later see if they exist using [..] > which should i use? delete() or undef()? obviously i could write a small > script to test this (which i'm going to know), but i'd also like to hear > from an

Re: delete vs undef

2004-07-09 Thread perl.org
On Fri, 9 Jul 2004 09:28:13 -0600, Wiggins d Anconia wrote > > > also, are these functionally equivalent? > > $myvar = undef(); > > undef($myvar); > > > > To my knowledge. Wait a second...I always thought undef was a constant value. Is it always a function or are there both? I don't know that

Re: delete vs undef

2004-07-09 Thread Wiggins d Anconia
> i want to remove items from a hash then later see if they exist using > defined(). for example: > You don't see if they exist using 'defined', you see if they are defined :-). To see if they exist, you use 'exists'. Which hits to the heart of your questions below. > delete($hash{MYKEY}); Th

delete vs undef

2004-07-09 Thread Christopher J. Bottaro
i want to remove items from a hash then later see if they exist using defined(). for example: delete($hash{MYKEY}); # blah blah if (defined($hash{MYKEY})) { # do blah blah } which should i use? delete() or undef()? obviously i could write a small script to test this (which i'm goi