in reply to how to get length of each line of file with spaces

Because a TAB is a single ASCII character represented by one octet / byte (pay no attention to the Unicode behind the curtain . . .); it's only by convention that it's displayed as four (or two, or eight, or . . .). You'd need to do something to expand it to spaces (e.g. s{\t}{    }gx) before you count if you're going to use length.

Edit: Also, ALWAYS CHECK THE RETURN VALUE FROM open.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: how to get length of each line of file with spaces
by Eily (Monsignor) on May 17, 2019 at 19:38 UTC

    Except when using autodie (in which case open doesn't return anything on failure I suppose?)

      Except when using autodie (in which case open doesn't return anything on failure I suppose?)

      Right. The open wrapper created by autodie dies instead of returning. (This happens somewhere in Fatal, from which autodie inherits almost everything.)

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)