in reply to how do $x = \12 differ from $$y = 12 ?

There is a world of difference. Forget that you're using a constant (12) for now. Imagine this:
my @data = ('a', 'b', 'c'); my ($x, $y); $x = \@data; @$y = @data;
$x refers to @data (that is, it holds a reference to @data). But $y doesn't; rather, the array referenced in $y holds a shallow copy of the elements in @data.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: how do $x = \12 differ from $$y = 12 ?
by borisz (Canon) on May 10, 2005 at 13:12 UTC
    Thanks, that takes me closer to the answer. I wonder why $y is undefined now.
    use Scalar::Util qw/weaken/; my ( $x, $y ); $x = \12; $$y = 12; weaken($x); weaken($y); print $x; print $y; __OUTPUT__ SCALAR(0x1807f24) Use of uninitialized value in print at 5432.pl line 11.
    Boris
      Someone else showed you Devel::Peek code that explains that. $x has a refcount of 2, and $y only has a refcount of 1. It's the same as doing:
      $x = \@array; $y = [];
      There, $x has a refcount of 2 (from $x and @array), whereas $y has a refcount of only 1.

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart