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

YAML also serializes functions but to a text format.
Internally it's using B::Deparse as well.