On Tue, 17 Apr 2001, Pacifico wrote:
> i have this program:
>
> $sup1='a';
> $sup2='b';
> $sup3='c';
>
> for ($i=1 ; $i<4 ;$i++){
> print $sup($i);
> }
>
> but give error, why???
Because, basically, you can't do that. To get the result you want, you
have to do this instead:
# Begin perl code
$sup1='a';
$sup2='b';
$sup3='c';
for ($i=1; $i<4; $i++) {
print ${'$sup'.$i};
}
# End perl code
This works because of a pretty complex process called 'symbolic
references', which is probably NOT what you want to mess with.
What is more likely, is that you want to use an array:
# Begin perl code
@sup = ('a', 'b', 'c'); # A nice little three-element array
foreach $i (@sup) { # $i is set to each element of @sup in turn.
print $i;
}
# End perl code
- D
<[EMAIL PROTECTED]>