sub parsevcard { my ($fh, $line) = @_; my $currentvcard = {}; # check that $line is really the beginning of a vcard, else die # loop reading lines from <$fh> and putting them in $currentvcard, call $currentvcard->{AGENT} = parsevcard($fh, $line) if a BEGIN:VCARD is encountered return $currentvcard; # check for end vcard? }