One thing at a time all the time!

Welcome to Rocteur
Saturday, April 27 2024 @ 04:16 AM CEST

How to Clear / Initialize a Hash

If you want to clear out the hash completely then:

%hash = ();

Will remove all the keys and values from the hash. This will also work
with a hash of hashes.

Or if you need to reinitialize it you can just assign the key/value
pairs to the hash:

%hash = ( newkey1 => 'newval1', newkey2 => 'newval2' );

Which will assign the new list, replacing anything that was in there
before.

John
--
use Perl;
program
fulfillment

FAQ Manager » Perl » How to Clear / Initialize a Hash