grabbing value of a variabe by its name?

Randal L. Schwartz merlyn at stonehenge.com
Thu Jul 25 16:05:34 UTC 2002


>>>>> "Ragnar" == Ragnar Hojland Espinosa <ragnar at linalco.com> writes:

Ragnar> I'll restate my problem again.

Ragnar>      $a = "hello";
Ragnar>      $b = "world";
Ragnar>      $c = "a";
Ragnar>      print $$c;     # references $a, and therferoe prints hello
Ragnar>      $c = "b";
Ragnar>      print $$c;     # and now prints world

If that's Perl, that's bad and evil Perl.  There are many better
ways to do that.

If that's PHP, that's a forced evil of PHP, and why I disrecommend PHP.

Please don't learn how to do that in Smalltalk.  I'm not even sure
it's possible, since method temps are lexically scoped.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



More information about the Squeak-dev mailing list