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


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???

What have we added to the long term maintainability of the code
by carbuncling it like this????


Why not compel the author down the road to understanding
how to do good data structures???


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to