go ahead... be a heretic | |
PerlMonks |
Re: evaluation strategy of perlby Sidhekin (Priest) |
on Sep 20, 2002 at 14:35 UTC ( [id://199488]=note: print w/replies, xml ) | Need Help?? |
Making a subroutine, if you want it to use values rather than variables, the way to do it is string eval. ("evaluation strategy", indeed.)
However, you will note that since the value of $i through this loop was 0, 1, and 2, that's what you get in output as well ... not 1, 2, and 3 :-) Alternatively, you can choose to use variables, but then you need three variables. The above code makes only one. The below code uses three variables (all with the same name), and also prints 0, 1, and 2:
The Sidhekin
In Section
Seekers of Perl Wisdom
|
|