Mailing List Archive

JAPH doesn't run
I was just perusing the JAPH's and found:

print pack('C25', grep($_ && $_ -= 256, split(/(\d\d\d)/, <<STRANGE)));
330373371372288353366367372360357370288336357370364288360353355363357370300
STRANGE

Which works fine under perl 4, but under 5 says:

Can't modify logical and in subtraction at - line 1, near "256,"
Execution of - aborted due to compilation errors.

Did something change?

--
Aaron Sherman <ajs@ajs.com> This " " B4 f w+ c kv s+(--)v r p
I-Kinetics, Inc. for rent Pager: (508)545-0584
1 NE Executive Park Fax: (617)270-4979
Burlington, MA 01803-5005 Desk: (617)252-3489
ajs@ajs.com or ajs@openmarket.com WWW: http://ajs.com/~ajs/
Re: JAPH doesn't run [ In reply to ]
Re: JAPH doesn't run [ In reply to ]
> I was just perusing the JAPH's and found:

> print pack('C25', grep($_ && $_ -= 256, split(/(\d\d\d)/, <<STRANGE)));
> 330373371372288353366367372360357370288336357370364288360353355363357370300
> STRANGE

> Which works fine under perl 4, but under 5 says:

> Can't modify logical and in subtraction at - line 1, near "256,"
> Execution of - aborted due to compilation errors.

A famous precedence bug in perl4:

k@leonardo:~% perl4.036 -e '
$foo eq "bar" || $bar = "foo";
print "foo [$foo] bar [$bar]\n";
'
Illegal expression (OR) as lvalue in file /tmp/perl-e002461 at line 2, next 2 tokens ""foo";"
Execution of /tmp/perl-e002461 aborted due to compilation errors.
zsh: exit 2 perl4.036 -e



k@leonardo:~% perl4.036 -e '
$foo eq "bar" || $bar = "" . "foo";
print "foo [$foo] bar [$bar]\n";
'
Illegal expression (OR) as lvalue in file /tmp/perl-e002462 at line 2, next 2 tokens ""foo";"
Execution of /tmp/perl-e002462 aborted due to compilation errors.
zsh: exit 2 perl4.036 -e



k@leonardo:~% perl4.036 -e '
$foo eq "bar" || $bar .= "foo";
print "foo [$foo] bar [$bar]\n";
'
foo [] bar [foo]


andreas
Re: JAPH doesn't run [ In reply to ]
:
: > I was just perusing the JAPH's and found:
:
: > print pack('C25', grep($_ && $_ -= 256, split(/(\d\d\d)/, <<STRANGE)));
: > 330373371372288353366367372360357370288336357370364288360353355363357370300
: > STRANGE
:
: > Which works fine under perl 4, but under 5 says:
:
: > Can't modify logical and in subtraction at - line 1, near "256,"
: > Execution of - aborted due to compilation errors.
:
: A famous precedence bug in perl4:
:
: k@leonardo:~% perl4.036 -e '
: $foo eq "bar" || $bar = "foo";
: print "foo [$foo] bar [$bar]\n";
: '
: Illegal expression (OR) as lvalue in file /tmp/perl-e002461 at line 2, next 2 tokens ""foo";"
: Execution of /tmp/perl-e002461 aborted due to compilation errors.
: zsh: exit 2 perl4.036 -e
:
:
:
: k@leonardo:~% perl4.036 -e '
: $foo eq "bar" || $bar = "" . "foo";
: print "foo [$foo] bar [$bar]\n";
: '
: Illegal expression (OR) as lvalue in file /tmp/perl-e002462 at line 2, next 2 tokens ""foo";"
: Execution of /tmp/perl-e002462 aborted due to compilation errors.
: zsh: exit 2 perl4.036 -e
:
:
:
: k@leonardo:~% perl4.036 -e '
: $foo eq "bar" || $bar .= "foo";
: print "foo [$foo] bar [$bar]\n";
: '
: foo [] bar [foo]

Note that it's the last of those that illustrates the bug by working.
The earlier errors are correct. The precedence of assignment operators
should be the same as the assignment operator.

Larry