in reply to Re^3: Useless use of private variable in void context
in thread Useless use of private variable in void context

Only if you use for (my $i; ... ) the variable has the old value again.

$i = 3; for (my $i = 0; $i < 30; $i++) { # \ # do something here # | scope of inner $i variable } # / print $i, "\n"; # prints 3 because it's the outer variable again

Regarding your second question, that's really a matter of preference and learning. If you plan to do more with perl, it will pay off to learn common Perl idioms, and use them.

If you have access to a public library, I'd very much recommend the book Programming Perl by Wall, Christiansen and Orwant

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^5: Useless use of private variable in void context
by okarmi (Initiate) on Oct 12, 2009 at 11:28 UTC

    Thank you again for your wisdom and patience!

    okarmi