You don't need to set arrays to empty at declaration time - they start out that way.

Rather than using shift to pull off parameters one at a time in various scattered locations through your sub, use list assignment with a declaration of a list of variables at the top of the sub.

If you have a reasonable variable name adding a comment that simply reiterates the variable name in expanded form doesn't add any information.

Taking all that into account your code sample becomes:

my @isec; my @b; (@b, @isec) = ArrayFunctions(\@ArrayA, \@ArrayB, \@b, \@isec); sub ArrayFunctions { my ($a_ref, $b_ref, $b, $isec) = @_; my @a = @$a_ref; my @b = @$b_ref; my %Aseen = map {$_ => undef} @a; my %Bseen = map {$_ => undef} @b; #.......... Other Code ..... }

Oh, and misleading comments are worse than no comment. There was a mismatch between the names of the hashes in the sub and the comment so I removed the comment. If the comment was right and names are wrong, change the names (and still omit the comment).


True laziness is hard work

In reply to Re: Syntax error for the following ??? by GrandFather
in thread Syntax error for the following ??? by mr_p

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.