in reply to risk of confusion

So the relevant parts of your code are, along with the question:
my $analysis_file = shift; open INFILE_1, '<', $analysis_file or die "Can't open '$analysis_file': $!\n"; while(<INFILE_1>) { my $ALL_FT_FILE = $_; # or some part of $_ after munging open INFILE_2, '<', $ALL_FT_FILE or die "Can't open '$ALL_FT_FILE': $!\n"; while(<INFILE_2>) { ... # is the outer $_ clobbered here? } }

That's considerably shorter, and more to the point, isn't it?

Answer: No, each $_ is localized to its own while() block. But you can't access the contents of the outer $_ from the inner block, unless you assign that to another variable.

<update>

*Sigh*. As jdporter pointed out, yes, $_ isn't localized in a while loop:

open O, '>', 'foo'; print O "bar\n"; close O; open O, '>', 'bar'; print O "$_\n" for qw(foo quux wrdlbrmfd); close O; open I, '<', 'foo'; while (<I>) { chop; open II, '<', $_ if -f $_; while (<II>) { print; } print "\$_ = '$_'\n"; } __END__ foo quux wrdlbrmfd $_ = ''

As you see at the last line of the ouput above, $_ is clobbered.

</update>

Some nits:

</pedantic> :)

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: risk of confusion
by jdporter (Paladin) on Aug 07, 2007 at 18:56 UTC
    each $_ is localized to its own while() block.

    I'm sorry, that is false. Are you getting while confused with foreach?

    As it says in When to Still Use local():

    it's important to localize $_ in any routine that assigns to it. Look out for implicit assignments in while conditionals.
    So the correct answer to the OP is actually Yes, there will be "confusion". local can be used to remedy the problem.

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
      Are you getting while confused with foreach?

      Obviously. Thanks for the correction. I'm very sorry about having propagated crap *blush*... maybe the corrections do mend that.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}