Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Removing an Element from a Hash

by straywalrus (Friar)
on Apr 23, 2002 at 01:54 UTC ( [id://161192]=perlquestion: print w/replies, xml ) Need Help??

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*

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://161192]
Approved by VSarkiss
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2024-04-19 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found