When $x and $y aren't initialized, there is no functional difference. The difference is only noticeable when they've been previously initialized.
my ( $x, $y );
$x = \12;
$$y = 13;
my $a = $x;
my $b = $y;
$x = \14;
$$y = 15;
print("a = $$a\n"); # 12
print("b = $$b\n"); # 15
print("x = $$x\n"); # 14
print("y = $$y\n"); # 15
$x = \14 create a reference to the constant 14. It then stores the reference in $x, erasing $x's previous content.
$$y = 15 replaces the value of the variable at which $y points with 15. In my example, $b points to that same variable. When $y isn't initialized, a new variable is created through auto-vivification. In languages without auto-vivification (C, C++ and Java, for example), you get a NULL pointer error instead. In languages with auto-vivification, you just created a new variable, possibly by accident.
In C++ parlance, $x = \14 is similar to
x = new int;
*x = 14;
while $$y = 15 is similar to
if (y == NULL) {
y = new int;
}
*y = 15;
|