Re: When does a hash of lists get defined?

2006-04-05 Thread Stewart Leicester
'defined' will autovivify, 'exists' will not. No, Bruce is right. When used with nested structures, both defined() and exists() will create the hash element "D", and store a reference to an anonymous array in it. But don't take my word for it - just ask Perl. Here's a simple test: Oops,

Re: When does a hash of lists get defined?

2006-04-05 Thread Joel Rees
'defined' will autovivify, 'exists' will not. I'll leave it up to Doug to decide if knowing that helps. The Camel book, page 710 in the third edition is very clear that exists goes the same way as defined. But perl has gone through a couple of new versions since it was written. Thanks to Ste

Re: When does a hash of lists get defined?

2006-04-05 Thread Doug McNutt
At 08:41 -0700 4/5/06, Stewart Leicester wrote: > >'defined' will autovivify, 'exists' will not. I'll leave it up to Doug to >decide if knowing that helps. The Camel book, page 710 in the third edition is very clear that exists goes the same way as defined. But perl has gone through a couple of

Re: When does a hash of lists get defined?

2006-04-05 Thread Sherm Pendley
On Apr 5, 2006, at 11:41 AM, Stewart Leicester wrote: Actually, those mean different things. Neither autovivifies, which was what Doug was seeking to understand. Both defined $phash{"D"}[3] and exists $phash{"D"}[3] autovivify $phash{"D"}. - Bruce 'defined' will autovivify, 'exist

Re: When does a hash of lists get defined?

2006-04-05 Thread Bruce Van Allen
On 4/5/06 Stewart Leicester wrote: >Bruce Van Allen wrote: >>Both >> defined $phash{"D"}[3] >>and >> exists $phash{"D"}[3] >> >>autovivify $phash{"D"}. >> >>- Bruce > >'defined' will autovivify, 'exists' will not. I'll leave it up to >Doug to decide if knowing that helps. Oh? Try this: #

Re: When does a hash of lists get defined?

2006-04-05 Thread Stewart Leicester
Actually, those mean different things. Neither autovivifies, which was what Doug was seeking to understand. Both defined $phash{"D"}[3] and exists $phash{"D"}[3] autovivify $phash{"D"}. - Bruce 'defined' will autovivify, 'exists' will not. I'll leave it up to Doug to decide if knowin

Re: When does a hash of lists get defined?

2006-04-04 Thread Bruce Van Allen
On 4/4/06 Stewart Leicester wrote: >>if (! defined $phash{"D"}) >> { >> print "\$phash{D} is undefined, We expected that.\n"; >> } > > >Instead of > >defined $phash{"D"} > >use > >exists $phash{"D"} Actually, those mean different things. Neither autovivifies, which was what Doug was se

Re: When does a hash of lists get defined?

2006-04-04 Thread Stewart Leicester
... if (! defined $phash{"D"}) { print "\$phash{D} is undefined, We expected that.\n"; } Instead of defined $phash{"D"} use exists $phash{"D"} This has bitten me before. Stewart -- Stewart Leicester | JenSoft Technologies, LLC "Per Ardua Ad Astra" |

Re: When does a hash of lists get defined?

2006-04-04 Thread Bruce Van Allen
On 4/4/06 Doug McNutt wrote: >While messing with CGI POSTed data I got trapped by this one. > >Version 5.8.1-RC3 for Mac OS 10.3.9 > >It appears that the hash element "D" gets defined in the process of >testing to see if an element in the associated string is defined. The >last if below takes the

Re: When does a hash of lists get defined?

2006-04-04 Thread Joel Rees
On 2006.4.5, at 09:36 AM, Doug McNutt wrote: While messing with CGI POSTed data I got trapped by this one. Version 5.8.1-RC3 for Mac OS 10.3.9 It appears that the hash element "D" gets defined in the process of testing to see if an element in the associated string is defined. The last if be

When does a hash of lists get defined?

2006-04-04 Thread Doug McNutt
While messing with CGI POSTed data I got trapped by this one. Version 5.8.1-RC3 for Mac OS 10.3.9 It appears that the hash element "D" gets defined in the process of testing to see if an element in the associated string is defined. The last if below takes the else route. Is that normal? Does i