Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
that doesn't mean the magic variable should not be provided at all, it just means it should be read-only.
That looks like inconsistency to me.
sub f1 { my ($x, $y) = @_; z($x, $y); }
sub f2 { z($_[0], $_[1]); }

Above two examples are not identical. Later one is something low-level, and it's just asking for trouble (for example in cases like f2($1), f2($.) or f2($x, $x) when z() modifies arguments ).
(NOTE: another common point of view is that caller of such functions is asking for trouble)

sub z { $_[0]++; print $_[1] } sub f1 { my ($x, $y) = @_; z($x, $y); } my $x = 4; f1($x, $x);
prints 4
sub z { $_[0]++; print $_[1] } sub f2 { z($_[0], $_[1]); } my $x = 4; f2($x, $x);
prints 5

So IMHO you should not use @_ just because it's shortest. Use it when you know what you're doing.

And now you suggest add another %_ which behaves completely different way.

Also making %_ readonly won't help much in cases when you pass magic variable as argument (example: RT#54728).

In reply to Re^4: Why doesn't Perl provide %_ as the hash equivalent of @_ in subs? by vsespb
in thread Why doesn't Perl provide %_ as the hash equivalent of @_ in subs? by smls

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [erix]: ital. neuter gave in to macho pressure

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (9)
    As of 2017-11-23 12:42 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (334 votes). Check out past polls.