in reply to Re^2: the variable is lost
in thread the variable is lost

I only see 19 lines of code. Which line is #38?

Update: Thanks for clarifying your code now.

Your while loop is reading <$fh> into $_, which is clobbering your foreach loop's version of $_. Since the topic variable in a foreach loop aliases the elements you're iterating over (ie, $a and $b), clobbering $_ clobbers $a and $b.

Use an explicitly named topic variable for your foreach loop.


Dave

Replies are listed 'Best First'.
Re^4: the variable is lost
by cruise (Acolyte) on Mar 09, 2012 at 08:42 UTC
    thanks for your help~~~~
    i have already know what's wrong with me
Re^4: the variable is lost
by cruise (Acolyte) on Mar 09, 2012 at 08:26 UTC
    i have update my full code ^_^
    it is only comment

      See my update above, and implement the advice by applying the following change:

      foreach my $filename ( $a, $b ) { open my $fh, '<', $filename or die $!;

      Dave