straywalrus has asked for the wisdom of the Perl Monks concerning the following question:

Does any one know how to remove an element from a hash? suppose I have:
html(name=>img,src="../hosted/image1.gif",width=>16,height=>16); sub html { %param = @_; print "<$param{name} "; foreach $key (keys (%param)) { print "$key=\"$param{$key}\" "; } print ">\n"; }
Now, I need to remove the value of $param{name}, but how do I do that? Shift? Some code to support your response would help. All the function html does is take the element name, and use every other element as HTML attributes, so that input renders:
<img src="../hosted/image1.gif" width="16" height="16">

Replies are listed 'Best First'.
Re: Removing an Element from a Hash
by dws (Chancellor) on Apr 23, 2002 at 01:58 UTC
    Now, I need to remove the value of $param{name}, but how do I do that?

    delete $param{name};

      Thanx
Re: Removing an Element from a Hash
by growlf (Pilgrim) on Apr 23, 2002 at 03:57 UTC
    You might also want to look at PerlDoc's faq entry on hashes for additional info.

    *G*