in reply to Printing Variable Variables
Update Note that using variable variables in this way walks around error checking that use strict provides and can lead to some pretty wierd run time behaviour. In general you should avoid the use of string eval unless you know exactly what is being evaled, and even then there are often better ways of achieving the result you need.use warnings; use strict; use strict; my $string0 = "Jessy"; my $string1 = "Bob"; my $string2 = "Nancy"; my $num = 0; while( $num != 3 ) { print eval "\$string$num"; $num++ }
In this case you could:
my @strings = ("Jessy", "Bob", "Nancy"); print join "", @strings;
for example. There are many other way to do this!
|
|---|