TS wrote:
> If I want to declare many variables $X1, $X2, $X3...$X20 and assign
> all these variables with same default value, 10, how could I do in
> short way instead of typing long nasty code like below?
>
> $X1=10;
> $X2=10;
> $X3=10;
> |
> |
> |
> $X20=10;
For e.g. three variables you can do:
my ($X1,$X2,$X3) = (10) x 3;
But are you sure you don't want an array
my @X = (10) x 20;
or a hash
my %X = map { $_ => 10 } 1..20;
instead?
--
Gunnar Hjalmarsson
Email:
http://www.gunnar.cc/cgi-bin/contact.pl