Can you clarify what your desired output is? I'm not sure I understand
you correctly, on the face of it you're looking for:
print join "var$digit", $var1, $var2;
....but I don't know why you'd want that :-)
Or, perhaps, you mean you wanted to preface each variable with its
name? It's much better to use a hash in this case:
my %data = (
var1 => 100,
var2 => 200,
);
# There's more than one way to do this; here's one.
while (my($key, $value) = each %data) {
print "$key is set to $value\n";
}
Hope this helps.
On Tue, Jan 6, 2009 at 5:33 PM, Chanan Berler <[email protected]> wrote:
> Hello All,
>
> I have the following prog:
>
> my $digit = 1;
> my $var1 = 100;
> my $var2 = 200;
>
> And I need to print $var1, $var2 - but using the $digit concatenated with
> the word 'var'.
> Can anyone help me? Suppose to be an easy task - but I got a blackout ..wow
>
> Thanks
> Chanan
>
> _______________________________________________
> Perl mailing list
> [email protected]
> http://perl.org.il/mailman/listinfo/perl
>
--
Gaal Yahas <[email protected]>
http://gaal.livejournal.com/
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl