Shawn H. Corey wrote: > Steve Bertrand wrote: >> I also really like your suggestion of putting the hashes within a sub. >> This will prevent the reset of ALL the data types each time new tests >> are run. >> > > You may want to look at dclone() from Storable. It clones deeply nested > structures.
I've used dclone in the past for other tasks, but Uri's suggestion fits the bill perfectly in this case (and in other cases ;) I create %typedefs hash, where each key is a name which has a value of a coderef that simply creates and returns a hash. Then: my @data_types = $vardb->is_type(); my @missing_types; for (@data_types) { push @missing_types, $_ and next if ! exists $typedefs{$_}; my %type = &{ $typedefs{$_} }; eval { $sanity->check_type( '$_', \%type, $error ) } ; unlike ( $@ '/Invalid data type/', "$_ is a valid and available data type" ); } The problem with all of the great feedback I get on this list, is that I always want to go back and rewrite the code where I've thought "I know there's a better way, but this way will work for now" ;) Cheers, Steve
smime.p7s
Description: S/MIME Cryptographic Signature