in reply to Line Number Confusion

close(FH) || (($failure = 1) && print("TestingFailure $. \n"));

You are closing the file handle before printing the value of $. The file's line counter gets reset by close() (See Variables related to filehandles)

Replies are listed 'Best First'.
Re^2: Line Number Confusion
by hmeharward (Novice) on Oct 01, 2015 at 20:25 UTC

    I moved $. to between open and close and now it says I have 12243 lines when I only have 546.

      Hi,
      I think you have the whole stuff mixed up. Please re-read all that has been posted on this thread already.
      Then I think you also need to read up the documentation on $.
      Simply, do perldoc -v $. from your CLI and you should have it.

      Here is an example, if you may:

      use warnings; use strict; my $look_for; while(<DATA>){ if (/^\./) { $look_for = $.; next; } print $., $_; } print "The dot came up on line ", $look_for, $/; __DATA__ Mary has a little lamb little lamb, little lamb . Mary has ....
      Output
      1Mary has a little lamb 2little lamb, little lamb 4Mary has .... The dot came up on line 3
      Hope that helps!

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me

        Thank you so much! That does help. I'll keep reading!