On Apr 30, David Gray said: >> Hi all - should be simple - but I cannot figure it out >> >> basically i want to name an array with a subscript ie >> world0[0] and world1[0] the 0/1 being a variable, i have tried to >> produce a simple example.... >> >> For any help - thanks.. >> ---------------------------------------------------------- >> @fred = "one,two,three,four"; >> >> $a=0; >> >> @array$a=split(/,/, @fred) >> >> for ($b=0;$b<4;$b++) { >> print @array$a[$b]; >> } > >Just FYI, it is possible to do that, like so:
NO! Don't teach how to do this, please. It can lead to security problems in your program; it also leads to having an unknown number of variables, and possibly, variables with names you don't know. Mark-Jason Dominus has an article about why using a variable as a name for a variable is a bad idea. Symbolic references are a left-over artifact from The Land Before Perl 5. They are wizardry, and should be avoided 99.9% of the time. There's about ONE place where you should use them, and even then, you probably don't need to. http://perl.plover.com/varvarname.html -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]