sub parsevcard { my ($inputstr, $inputpos, $depth) = @_; if ($depth > $max_depth) { # Recursion beyond allowable depth error handling here } . . $currentcard->{AGENT} = parsevcard($inputstr, $pos, ++$depth); }