Almost right,

sub fn { my ($fn_x, $fn_y) = @_; ($$fn_x, $$fn_y) = ('x', 'y'); my $rc = 0; $rc = 1 if $$fn_x ne 'x'; return 0; }
is what you want though. The references $fn_x and $fn_y should be dereferenced if you want to access/change the values they refer to. For a scalar, dereferencing is done with $, while @, % and & are used to dereference lists, hashes and functions respectively. E.g. suppose that $r_list is a reference to a list, you'd get the list it refers to using @$r_list while you'd get the second element of the list using $r_list->[1].

For the ocmplete story, have a look at perlref.

Incidently, you might want to die inside the function fn since this is where the exception actually occurs. The if statement can be replaced by eval {...}; and you can test for an error by checking the value of the variable $@.

Hope this helps, -gjb-


In reply to Re: Parameter passing by gjb
in thread Parameter passing by Anonymous Monk

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.