Thanks for the advice guys, both are things that will help
matt
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 21, 2001 10:54 AM
To: Matthew Thompson
Cc: activeperl
Subject: deleting hash values
Matthew Thompson writes:
> Hi,
> I'm using the following code to delete values from a hash - I get the
> warning (I say warning as it does delete the value) below when delete is
> called. Is ther a better way of deleting values from hashes?
>
> foreach $item (%$self) {
> if ($item=~/^$section\.(.*)/) {
> print "deleteing... $self->{$item}\n";
> delete $self->{$item};
> }
> }
>
> warning:
>
> deleteing... thompson
> Use of uninitialized value in pattern match (m//) at TutorialConfig.pm
line
> 132.
> Attempt to free unreferenced scalar at TutorialConfig.pm line 131.
I don't know if this is the problem here, but You do realise that your
foreach loop is iterating over keys AND values! I suspect that that is
not what you intended. Perhaps you should use:
foreach $item (keys %$self)
--
Brian Raven
To ordinary folks, conversion is not always automatic. It's something
that may or may not require explicit assistance. See Billy Graham. :-)
-- Larry Wall in <[EMAIL PROTECTED]>
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl