On Tue, 04 Dec 2007, [EMAIL PROTECTED] wrote:
> It's also a cautionary tale - if you're using the default "$_" in for
> loops, you can munge your original data.
> foreach my $foo ( @foo ) {
>    $foo =~ s/SID/12345/;
> }
> 
> this doesn't mess w/ @foo.

That is not correct; it will still modify @foo.  It only protects
you against functions that you might call inside of your for() loop
from messing with your values via $_, which is a global variable
in Perl 5.8.

Note that you can have a lexical $_ in 5.10:

    foreach  my $_  ( @foo ) {
       s/SID/12345/;
    }

Cheers,
-Jan

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to