tos has asked for the wisdom of the Perl Monks concerning the following question:
inspired by strats little 'regards-obscu' i played a little with the comma-operator.
I found this strange behavior
Okay, i'm thinking the '1' represents the successful processing of the second print which will be printed after the 'one'. The printing of 'two' at first seems to be dealing with the fact that the lefts of comma-separated values are thrown away and only the rightmost is returned.# perl -e 'print "one\n",print "two\n"' two one 1
When i tried another example i became really confused.
Why does the second print already know the value of $a, if the working direction is reverse ?# perl -we 'print $a=3,"\n",print $a-5,"\n"' -2 3 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: comma-operator quirks
by BrowserUk (Patriarch) on Jun 14, 2003 at 17:23 UTC | |
|
Re: comma-operator quirks
by TomDLux (Vicar) on Jun 14, 2003 at 16:57 UTC |