in reply to save to file: $h{'sub'}=sub{..};

If you are using Perl 5.8 (because you have to use B::Deparse 0.61 or higher), you can also do this with Storable:
# slightly modified from Storable docs use strict; use warnings; use Safe; use Storable qw(freeze thaw); my $safe = Safe->new(); $safe->permit(qw(:default require)); local $Storable::Deparse = 1; local $Storable::Eval = sub { $safe->reval($_[0]) }; my $serialized = freeze(sub { return 'hello world' }); my $code = thaw($serialized); print $code->(), "\n";

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)