Hey!
I discovered a bizarre behaviour of a perl script. Many people encouraged me to
ask for your opinion about this behaviour: It's a bug or a feature?
The script I am talking about is the following:
#!/usr/local/bin/perl
&bug_sub();
sub bug_sub {
my($i); # This my() makes no sense, but I need it
# to show the bizarre behaviour
for $i (0 .. 3) {
print($i, " ");
eval('0 < $i'); # This eval() does not change $i. Shure.
# This eval() makes no sense, of course!
print($i, " ");
eval('0 < $i*2.4'); # This eval() changes $i. Why?
print($i, "\n");
}
}
Running this script, I expect the following output:
0 0 0
1 1 1
2 2 2
3 3 3
Nevertheless, I recive the following output (On HP9000/S700 and on
IBM/RS6000, using "perl, version 5.001 Unofficial patchlevel 1m"):
0 0 0
1 1 2.4
2 2 4.8
3 3 7.2
Please have a look at it.
Thanks
Georg
I discovered a bizarre behaviour of a perl script. Many people encouraged me to
ask for your opinion about this behaviour: It's a bug or a feature?
The script I am talking about is the following:
#!/usr/local/bin/perl
&bug_sub();
sub bug_sub {
my($i); # This my() makes no sense, but I need it
# to show the bizarre behaviour
for $i (0 .. 3) {
print($i, " ");
eval('0 < $i'); # This eval() does not change $i. Shure.
# This eval() makes no sense, of course!
print($i, " ");
eval('0 < $i*2.4'); # This eval() changes $i. Why?
print($i, "\n");
}
}
Running this script, I expect the following output:
0 0 0
1 1 1
2 2 2
3 3 3
Nevertheless, I recive the following output (On HP9000/S700 and on
IBM/RS6000, using "perl, version 5.001 Unofficial patchlevel 1m"):
0 0 0
1 1 2.4
2 2 4.8
3 3 7.2
Please have a look at it.
Thanks
Georg