in reply to Re: Re: 'for' array being altered - scope
in thread 'for' array being altered - scope

That's all very correct1 and appreciated, but it tells neither me nor fireartist anything we did not already know.

See, in my case localizing $_ had to be done in the sub that assigned to it (local does dynamic scoping, not lexical), and my problem was finding which sub did such a nasty thing.

find -name '*.pm' | xargs grep '$_ =' did nothing to help me ...

fireartist's problem is similar. He knows that assigning to $_ has this effect. He just does not see where this assignment takes place.

1 <nitpick>... except that you are not so much avoiding assign operations as avoiding building a temporary array. The map version performs one assignment (to an array) total, while the for version performs one assignment (to a scalar) each time through the loop. Still, it is an optimization.</nitpick>

The Sidhekin
print "Just another Perl ${\(trickster and hacker)},"

Replies are listed 'Best First'.
Re: Re: Re: Re: 'for' array being altered - scope
by diotalevi (Canon) on Sep 26, 2002 at 12:49 UTC

    Duh! smacks forehead oops! Ok in that case it would be interesting to know where column_num lives to examine that source.