sub flatten { my ($struct) = @_; if (ref [] eq ref $struct) { return map flatten($_), @$struct } else { return \$_[0] # <- We need to use the alias, not a copy. } }