M�rcio Oliveira wrote:
> Hi All (again)!
>
> I have another question. How I can create a incremental var's name ?
>
> Ex:
>
> Read "n" numbers and create a var with the name terminate with the
> sequence number in a loop:
>
> $n = 4;
>
> while ($num ne $n) {
>
> create the "numbered var ";
> $num++;
> }
>
> in this example, the program create 4 vars:
>
> $varname1 = "x"
> $varname2 = "x"
> $varname3 = "x"
> $varname4 = "x"
>
> Obs: the "n" number is variable.
Use an array as previously suggested or a hash :
my %hash;
for (1 .. 4) {
$hash{"varname$_"} = $_;
}
print "$_ = $hash{$_}\n" foreach keys %hash;
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs