Hi

as far as I know hash keys must be strings.
So there simply can't be a undef() as a hashkey.

to prove what I said:

% perl -MData::Dumper -le '$hash{undef()} = "foo"; $hash{""} = "bar"; print 
Dumper \%hash'
 $VAR1 = {
          '' => 'bar'
        };


HTH Martin

On Thu, 14 Jun 2007 14:03:10 +0200
"Jenda Krynicky" <[EMAIL PROTECTED]> wrote:

> Date sent:            Thu, 14 Jun 2007 06:29:56 -0400
> From:                 Mathew Snyder <[EMAIL PROTECTED]>
> To:                   Perl Beginners <beginners@perl.org>
> Subject:              Hash Key is a Null Value
> 
> > I'm building a hash using values from a database backend to an application 
> > we
> > use in house.  The application has a field which contains a customer name.  
> > This
> > values is supposed to be set by the person handling the work but sometimes
> > doesn't get done.  This leaves a NULL value in the database which, in turn,
> > leaves me with a null key in my hash.
> > 
> > I've tried resetting it by assigning the value to another key so I can 
> > delete
> > the element but so far nothing has worked.  I've tried to access it with
> > $hash{}, $hash{""}, and $hash{''}.  None of these will allow me to access 
> > the data.
> 
>   $hash{undef()}
> 
> You need to use the () because otherwise Perl would automatically 
> quote the undef. So $hash{undef} is equivalent to $hash{'undef'}.
> 
> You might also do something like this:
> 
>   my $NULL;
>   print $hash{$NULL};
> 
> HTH, Jenda
> ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
> When it comes to wine, women and song, wizards are allowed 
> to get drunk and croon as much as they like.
>       -- Terry Pratchett in Sourcery
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to