When passing parameters, you want to pass scalars - which means you want to pass:
* scalars as themselves * each array as an array reference (a reference is a scalar) * each hash as a hash reference (a reference is a scalar)
so
1. there is no reason to pass a reference to $template(a scalar) to the subroutine - why not just pass $template? Forget about the reference - then in the subroutine you can do my ($output, $input) = @_; and just use $output in the subroutine, instead of having to use $$output. 2. when you pass \@temp_fyle in the call to subroutine file_expansion, that's fine. This is just my preference, but IMHO it helps keep your code simpler and more understandable if you name variables consistent with what they contain. For example, in subroutine file_expansion, name the imcoming parameter that is a reference to the array what it is - a reference, like this: my ($output, $input_arrayref) = @_; or maybe even better my ($output, $temp_fyle_arrayref) = @_; Then, since you can actually use the reference to point at array elements (instead of having to dereference the array reference into an array), you can do something like this print "first element is $temp_fyle_arrayref->[0]\n"; to refer to the 1st element of the array, instead of having to do my @new_array = @$temp_fyle_arrayref; my $first = @new_array[0]; print "first element is $first\n"; which takes more memory since you are creating another array(@new_array).
HTH.

In reply to Re: referencing question by hmerrill
in thread referencing question by bonoboy

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.