in reply to Re^2: how to find the length of any line of file -- oneliner
in thread how to find the length of any line of file

Yes, Discipulus, no need for a begin block because you're hard coding the line number, whereas I wanted to pass it as an argument to the script and therefore needed to retrieve it (only once). Now, of course, for a one-liner, you might as well hard code the line number, it doesn't make a big difference.
  • Comment on Re^3: how to find the length of any line of file -- oneliner

Replies are listed 'Best First'.
Re^4: how to find the length of any line of file -- oneliner
by Discipulus (Canon) on Nov 23, 2017 at 11:12 UTC
    Hello Laurent_R, curiously enough (for me!)

     perl -lne  "print length  and exit if $. == $ARGV[0]"  datatest.txt 4

    does not complains about: Can't open 4: No such file or directory at.. and works even without the BEGIN block

    It just runs ok with both passed as arguments, not with the data passed via pipe though.

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.