The problem I have is that I'm not sure what Function B is going to return. It may return a scalar, it may return an array or it may return a hash. It may even be a reference to one of these

That's not exactly right. Perl subroutines can return list of scalars. That's it. If you try to return something that isn't, it gets converted. The conversion occurs inside the function, so there's no way for the outside to know what was passed to return inside the function. Unfortunately, what you request cannot be done in Perl.

However, that doesn't mean there's no solution to your problem. There might be an alternative way of achieving what you want. Maybe there's a way of causing Function B that hasn't occured to you. Parse::RecDescent is very powerful and very flexible, so I'm sure we could find a way to help you if you were to post some of your code.


In reply to Re: Auto-detecting returned or passed variable type by ikegami
in thread Auto-detecting returned or passed variable type by richard5mith

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.