in reply to return codes from embedded subroutines

Are you looking for something like this?
use vars qw( $error ); sub do_lots { $error = 0; # assume things are correct unless told otherwise my %hash = @_; %hash = mangle_once(%hash); return $error if $error; %hash = mangle_twice(%hash); return $error if $error; # ... as necessary }
That assumes the embedded subs set the global $error when there's a problem.

You could also return hash refs from your embedded subs, capture them in a temporary value, and check for definedness:

my $result; $result = mangle_once(%hash); return $error unless defined $result; # et cetera
Returning either an error code or a flattened hash can be a little trickier, and I probably wouldn't do it as it would make the code less clear.