> On Tuesday, April 30, 2002, at 07:32 , David Gray wrote: > [..] > > my $fred = 'one,two,three,four'; > > my $a = 0; > > @{"array$a"} = split ',', $fred; > > > > for(0..3) { > > print ${"array$a"}[$b] > > } > > File "untitled text 2"; Line 21: Name "main::b" used only > once: possible > typo > File "untitled text 2"; Line 18: Can't use string ("array0") > as an ARRAY > ref while "strict refs" in use > > > yeah I can clean that up with > > my $fred = 'one,two,three,four'; > my $a = 0; > no strict 'refs'; > @{"array$a"} = split ',', $fred; > > foreach my $b(0..3) { > print ${"array$a"}[$b] ."\n" > } > > so as to get the output > > one > two > three > four
Yeah, that would be a clever typo, like it says in the cryptic error message. Sorry about that. > All of which drives me back to the question - why did we compel > ourselves to have to insert the > > "no strict 'refs';" > > given the quandery: > > > 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.... > > > why take the convolutions??? <http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=quandery> Question, perhaps? <http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=convolutions> 3. a complication or intricacy of form, design, or structure I don't use these "convolutions" of perl for large programming projects or for sensitive cgi scripts, unless they are in a very otherwise static and controlled environment, like in that example. I also find that it's only more confusing to be sesquipedalian in response to posts that only need a simple, clear answer. > What have we added to the long term maintainability of the > code by carbuncling it like this???? <http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=carbuncling> I'll assume you mean that code is confusing. But it's not. It's very simple. It's a very easy way to perform aggregate functions on several sets of data, as long as you're careful to make sure your code doesn't have any stupid side effects, like what Jeff described. > Why not compel the author down the road to understanding > how to do good data structures??? Everyone else who responded to the thread did that, and very well I thought. Perhaps, however, the OP has a simple script that would be simplified even more if he knew how to use dynamic variables. Sometimes, when a simple script is the easiest solution to the problem, it's worth more to just get it working than to spend time developing a complex data structure. -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]