2009/11/25 kusuma ramaswamy <rkus...@gmail.com>: > Hello, I am new to perl. I would like to know how to toggle a variable with > each iteration in a loop ??
Hi, I'm not entirely sure that I understand your requirements but this might get you started. You want to scope your variables with the keyword `my`, so #!/path/to/perl use strict; use warnings; ... foreach my $colour (qw/red green yellow blue/) { print "$var\n" } red green yellow blue The variable $colour will be changed with each iteration of the loop. Have a look at http://perldoc.perl.org/perlsyn.html#Foreach-Loops for more details. HTH, Dp. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/