#!/afs/athena/contrib/perl5/p -w

use strict;
use Symbol;

sub magic {
  my(@args)= @_;
  return sub { print @_, @args; }
}

my ($a)='something';
my ($b)='something';
my ($c)='else';

my ($x)=\$a;
my ($y)=\$b;
my ($z)=\$c;

my ($q)=[$a, $b, $c];
my ($w)={a => $a, b => $b};
my ($e)=gensym;
my ($r)=gensym;

my ($n)= magic("\n");
my ($m)= magic("\n");

&$n('Hello');
&$n('world');

my(@refs) = (\$a, $x, \$b, $y, \$c, $z, $q, $w, $e, $r, $n, $m);
my ($i, $j, $k);

for $i (0..$#refs) {
  printf "\$refs[$i] = %s [num: 0x%x]\n", $refs[$i], ($refs[$i]+0);
}

for $i (0..$#refs) {
  for $j ($i..$#refs) {
    print "\$refs[$i] == \$refs[$j]\n" if ($refs[$i] == $refs[$j]);
    print "\$refs[$i] eq \$refs[$j]\n" if ($refs[$i] eq $refs[$j]);
  }
}

