[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Dereferencing



It seems that the $$ is the magic operator for scalar variables...
Have a look at this code. Now I will test it for a GD::Image object
and see if it works the same.

Charles


#!perl -w

$fred = "Dogs";

$frog = \$fred;   

$mouse = $$frog;

print "Frog  is $frog\n";
print "Mouse is $mouse\n";
&checkit($frog);
print "Frog  is now $frog\n";
print "Fred  is now $fred\n";

sub checkit {
   my($ref) = @_;
   $horse = $$ref;
   print "Horse is $horse\n";
   $$ref = "Black Beauty";
   return;
}


Output:

FFrog  is SCALAR(0x88bd1c)
Mouse is Dogs
Horse is Dogs
Frog  is now SCALAR(0x88bd1c)    <- still the same!
Fred  is now Black Beauty

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org