Timothy Johnson wrote:
>
> Okay, that makes sense after playing around with it a little. One more
> question. Does that offer an advantage over doing this?
>
> use strict;
> our @list = qw(a b c d);
> foreach (@list) {
> &check_b;
> print $_, "\n";
> }
>
> sub check_b {
> foreach (@list) {
> my $string = $_; #instead of local $_
> $string =~ s/b/bb/;
> # SAVE TO FILE
> }
> }
>From what I understand, there's no major difference.
In fact, what you've done is made a "local" copy of $_ and named it
$string, in order to *not* make changes to $_, itself.
>From what I've gleaned from the docs, this is very similar to what Perl
does when it implements local or my. In that, when Perl sees 'local $_',
it says to itself, "Ok, I gotta save whatever is in $_ somewhere under
a different name so that it doesn't get changed while it's being used
in this particular block." And then after the block, Perl restores $_ to
it's original value.
So, it's six of one and half dozen of the other, (or whatever that saying is).
Bompa
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]