perl (level 29) bug on assignment ('=')

Bob Best bob at dhw68k.cts.com
Tue Mar 22 02:39:50 AEST 1988


The following perl test script manifests bugs when executed under patchlevel 29
as compiled to run under SCO Xenix 386 V2.2.2.  The bugs are evident in the
output that follows the script listing.  Tests 1a,b,c clearly indicate that
perl is not properly handling the assignment operation as applied to strings
using the same variable on both sides of the '=' sign.  Notice that the
bug is eliminated by concatenation of a null string either before or after
the test string expression.

#!./perl

#  op.assign - test assignment using same variable left and right of '='

$x = "dog";
$x = "#1a\t:$x: eq :dog:\n";
print $x;

$x = "dog";
$x = ""."#1b\t:$x: eq :dog:\n";
print $x;

$x = "dog";
$x = "#1c\t:$x: eq :dog:\n"."";
print $x;

$x = "dog";
$x = "#2\t:"."$x".": eq :dog:\n";
print $x;

$x = "dog";
$x = "#3\t:"."$x: eq :dog:\n";
print $x;

$x = "dog";
$x = "#4\t:$x".": eq :dog:\n";
print $x;

$x = "dog";
$x = "#5\t:".$x.": eq :dog:\n";
print $x;

$x = "dog";
$y = "dog";
$x = "#6a\t:$x: eq :$y:\n";
print $x;
$x = "dog";
$y = "dog";
$y = "#6b\t:$x: eq :$y:\n";
print $y;
$x = "dog";
$y = "dog";
$y = "#6c\t:$x: e"."q :$y:\n";
print $y;

$x = "dog";
$y = "#7\t:";
$z = ": eq :dog:\n";
$x = "$y"."$x"."$z";
print $x;

$x = "dog";
$y = "#8\t:";
$z = ": eq :dog:\n";
$x = $y.$x.$z;
print $x;

$x = "dog";
$y = "#9\t:";
$z = ": eq :dog:\n";
$x = "$y$x$z";
print $x;

$x = "dog";
$y = "#10\t:";
$z = ": eq :dog:\n";
$x = "$y$x"."$z";
print $x;

$x = "dog";
$y = "#11\t:";
$z = ": eq :dog:\n";
$x = "$y"."$x$z";
print $x;

$x = "dog";
$y = "#12\t:";
$z = ": eq :dog:\n";
$x = "$y"."$x"."$z";
print $x;

$x = "dog";
print "#13\t:";
print $x;
print ": eq :dog:\n";

$x = "dog";
$x = "$x";
print "#14\t:";
print $x;
print ": eq :dog:\n";

$x = "dog";
$x = "$x"."";
print "#15\t:";
print $x;
print ": eq :dog:\n";

$x = "dog";
$x = ""."$x";
print "#16\t:";
print $x;
print ": eq :dog:\n";

This is the output produced by running the script under perl patchlevel 29.

#1a	:#1a	:: eq :dog:
#1b	:dog: eq :dog:
#1c	:dog: eq :dog:
#2	:dog: eq :dog:
#3	:dog: eq :dog:
#4	:dog: eq :dog:
#5	:dog: eq :dog:
#6a	:#6a	:: eq :dog:
#6b	:dog: eq :#6b	:dog: eq ::
#6c	:dog: eq :dog:
#7	:dog: eq :dog:
#8	:dog: eq :dog:
#9	:#9	:: eq :dog:
#10	:dog: eq :dog:
#11	:dog: eq :dog:
#12	:dog: eq :dog:
#13	:dog: eq :dog:
#14	:: eq :dog:
#15	:dog: eq :dog:
#16	:dog: eq :dog:

-- 
Bob Best
uucp: ...{trwrb,hplabs}!felix!dhw68k!bob	InterNet: bob at dhw68k.cts.com



More information about the Comp.sources.bugs mailing list