Re: is there a simple way get the current line number of processed file?



On May 27, bingfeng zhao said:

To parse a regular text file, I should report the line number of parsed file
when error occured. I want to know whether perl provide a shortcut way or
magic '$?' indicate this. I must counting myself if not.

When reading from a filehandle, the $. variable holds the current line number.


--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart
.



Relevant Pages

  • Re: is there a simple way get the current line number of processed file?
    ... I want to know whether perl provide a shortcut way or ... I must counting myself if not. ... Prev by Date: ...
    (perl.beginners)
  • Re: Counting lines in big number of files - in parallel.
    ... generates some reports for me and this script needs to count the ... But the above sequencial counting is very slow. ... You're using Perl like a batch script. ... Your first line above needs to start a shell, ...
    (comp.lang.perl.misc)
  • Re: counter program by using closure
    ... John W. Krahn wrote: ... how does perl know in this instance that %2d is refering ... is substituted for '%2d' in $counting. ...
    (perl.beginners)
  • Re: python vs perl lines of code
    ... Counting as 3 would reward things ... Well it's all over the Perl Cookbook. ... You can even find examples on my site that use imported functions (which I ...
    (comp.lang.python)
  • Re: counter program by using closure
    ... John W. Krahn wrote: ... how does perl know in this instance that %2d is refering to $count.. ... $counting contains the format string for printfand the first argument $clear is substituted for '%s' in $counting and the second argument ++$count is substituted for '%2d' in $counting. ...
    (perl.beginners)