I think the moral of the story is "understand what you are passing to your functions".
It appears that most ways that one might modify a variable in a function call will result in an alias to the variable being passed. Post-increment seems to be unique in that it creates an anonymous value.
C:\>perl -e "sub foo{ print join qq/\n/, map { \$_ .' - ' . $_ } @_ }
+foo($i=1,++$i,$i++,$i+1,$i+=1,$i);
SCALAR(0x183059c) - 4
SCALAR(0x183059c) - 4
SCALAR(0x225f7c) - 2
SCALAR(0x18305fc) - 4
SCALAR(0x183059c) - 4
SCALAR(0x183059c) - 4
-
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.
|