If efficiency matters, use Storable as suggested by others.
In reply to Re: Recreating hash from Data::Dumper text by tilly in thread Recreating hash from Data::Dumper text by theguvnor