in reply to Reference to a function
#All print statements printed "Clinton"###His code $GlobalName = "Clinton"; sub getGlobalName { return($GlobalName); } print "Before: " . &getGlobalName() . "\n"; $ref = \&getGlobalName(); $$ref = "Gore"; print "After: " . &getGlobalName() . "\n";
#Prints "Clinton" then "Gore" What he did was way off. He created a reference hard reference with:###His code improved $GlobalName = "Clinton"; sub getGlobalName { return($GlobalName); } print "Before: " . &getGlobalName() . "\n"; $GlobalName = "Gore"; print "After: " . &getGlobalName() . "\n";
If you were to:$ref = \&getGlobalName();
It would look something like:print "$ref \n";
What he said was the same as:CODE(0x1a45934)
or creating a soft reference.${CODE(0x1a45934)} = "Gore"
|
|---|