It's all about forcing a context.
@array = qw/ a b c /; $scalar = @array; # puts @array into scalar context print $scalar; # '3' ($scalar) = @array; # forces @array into list context print $scalar; # 'a' ($a, $b, $c) = @array; # likewise print "$a, $b, $c"; # 'a, b, c'
The use of 'my' doesn't change the way parens (or lack thereof) affect the context of the variables. You've figured out that shift returns a single scalar: the left-most item in @array. The difference between that and the 2nd method above (what you were using previously), is that the array itself is unchanged. Shift modifies it, so subsequent calls will get you something different, whereas the assignment in the list context above will always give you the same values.

This also is what allows us to do things like this:

($a, $b) = ($b, $a); # swap print "$a, $b, $c"; # 'b, a, c'

In reply to Re: using 'my $var' vs. 'my($var)' by Fastolfe
in thread using 'my $var' vs. 'my($var)' by decnartne

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.