in reply to hash in SDBM_File

The best way to store data structures such as these intact is to serialise them prior to storage - There are a number of ways by which this can be performed but one of the fastest and most widely employed is through the Storable module. This module allows complex data structures to be broken down to storable and retrieveable serial strings via the freeze method, which can subsequently stored in files and then restored to the original data structure via the thaw method. eg.

use Storable qw/ freeze thaw /; # Create serial representation of hash structure $serialised = freeze \%hash; . . . # Recreate hash structure from serial representation %hash = %{ thaw( $serialised ) }

Other modules which allow the representation and storable of complex data structures within serial formats include Data::Dumper and Data::Denter - The primary advantage which Storable offers over these modules is speed.

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'