Perl module to deal with numbered nested objects
Just a few remarks about parts which poke the eye,

    push @ar, sub {
        return (undef) unless exists $obj-&gt;{$i};
        return squash($obj-&gt;{$i});
    }-&gt;();


introduces unnecessary subroutine call/overhead which can be replaced with do {} block, or even simpler,

    push @ar, exists $obj-&gt;{$i} ? squash($obj-&gt;{$i}) : undef;


This one is only matter of taste, so

return $obj unless ref $obj eq 'HASH';


could also be written as

return $obj if ref $obj ne 'HASH';


Usually you don't have to explicitly return undef, as in list context you may end up with list one element long, and that might not be what is intended. Instead just return; or return (); will produce empty list, or undef in scalar context. So

return (undef) if @{$obj} == 0;


could be better as

return () if @{$obj} == 0;


or perhaps,

@$obj or return;