Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

clearly, there are two different mechanisms: the first does not do aliasing, whereas the second does.

How can you claim that for(1..3) doesn't alias when you can clearly see ++$_; having an effect on what it returns?

In both for(1..3) and for(1), $_ is aliased to each value returned by the expression in the parens.

I'm sorry, but you're dead wrong here:

First, your example does not demonstrate a lack of aliasing. It just shows that $_ isn't aliased to $a. That's to be expected, because 1..$a doesn't return $a anymore than 0+$a does.

Second, you pulled a switcheroo. I said for(1..3) aliases (and proved that it does), but your code uses for(1..$a). for(1..$a) is implemented differently; it's a counting loop and not a foreach loop. It still aliases, though.

Is there any proof of that intention? Best in perldoc?

There was code written to specifically perform this effect. By definition, the effect must be intentional.


In reply to Re^17: ref to read-only alias ... why? (notabug) by ikegami
in thread ref to read-only alias ... why? by dk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found