-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(($x = 3) == ($x = 4)) evaluates to 1 #466
Comments
From lucs@CAM.ORGIf the value of the expression ($x = 3) is 3, and that of ($x = 4) is ($a =~ m/(\d)/ ? $1 : 0) <=> ($b =~ m/(\d)/ ? $1 : 0) I suspect that optimizations are at work, but found nothing in the Perl Info
|
From @tamiasOn Wed, Sep 01, 1999 at 01:33:40PM -0400, Luc St-Louis wrote:
I would say that this is for the same reason that ($x = 1, ++$x, ++$x) returns the list (3, 3, 3). ($x = 3) assigns 3 to $x, and pushes a reference to $x on the stack. (($x = 3) == ($x = 4)) pops both references to $x from the stack, and Ronald |
From [Unknown Contact. See original ticket]On Wed, 01 Sep 1999 at 17:42:24 -0400, Ronald J Kimball wrote:
Side-effects, as explained by Ronald.
I assume that this is the code you're really interested in, and there This works around the problem: (Note that I've changed the REs a little, sort { (my $junk = $a =~ m/(\d+)/ ? $1 : 0) <=> ($b =~ m/(\d+)/ ? $1 : 0) } Just making Perl save the first sub-expression is enough to fix it. Ian |
From [Unknown Contact. See original ticket]Luc St-Louis <lucs@CAM.ORG> writes:
Because $x == $x. -- |
From [Unknown Contact. See original ticket]Ian Phillipps <ian@dial.pipex.com> wrote
[ Just guessing, without looking at the Perl source ... ] I'd quite expect it to be so held. Remember that a conditional can Mike Guy |
Migrated from rt.perl.org#1307 (status was 'resolved')
Searchable as RT1307$
The text was updated successfully, but these errors were encountered: