> -----Original Message-----
> From: Scott Lutz [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 30, 2002 2:00 AM
> To: Beginners Perl
> Subject: dynamic array values
> 
> 
> Here is the story:
> "@array" with unknown number of elements, that I want to 
> cycle through while
> assigning variables to each value in the loop like this:
> 
> __snip__
> 
> foreach my $domain ( @DOMAINS_ORDERED ){
>         (my $DOM_NAME, my $TLD) = split(/\./, $domain, 2); 
> #split the domain
> into 2, so we can extract the "TLD"
>         $count++;
>         #$price_total = $price_total + $TLD_DEF{$TLD}; # old school
>         $price_total += $TLD_DEF{$TLD}; # new school :)
> }
> 
> __end_snip__
> 
> But what I would like is this : if there are two or three 
> elements in the
> array then come out with $var1 $var2 $var3, which ever, but 
> only declaring
> them if they exist. 

Why do you want to do this? What good will having an unknown
number of different variable names do you? How will you access
them? How will you know how many there are?

Use arrays and hashes to hold collections of things, not separate
scalar variables.

> I have looked over the camel and lama 
> books but am not
> exactly what I am looking for, "dynamic array variables"?
> 
> I am looking for some assistance here, and what to keep this 
> as dynamic as
> possible, and want to be able to refer to the variable 
> contents later in the
> script if need be ( this is the whole point of the matter ).

Use arrays or hashes.

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

Reply via email to