in reply to Re^3: Perl : Split/Regex
in thread Perl : Split/Regex

..That works, but what if you just so happen to have a "Y" in the third field?..

For the lines without the Y there would be no *fourth field counting from 0, check or count it.
And even if you decide to include Y in the those lines last field if($fields[-1] eq 'Y'){.. would still work.


*Updated this in light of the discuss that follows! Which has nothing to do with the level of correctness as some may presume.
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

Replies are listed 'Best First'.
Re^5: Perl : Split/Regex
by AppleFritter (Vicar) on Sep 03, 2014 at 23:29 UTC

    For the lines without the Y there would be no thirdth field counting from 0, check or count it.

    Correction: there would be no $field[3], but that's the fourth field, not the third, as one conventionally starts to count at one, not zero. (If you disagree, ask yourself how many hands you have, for instance. Is it one or two?)

    I thought that this did not need to be said.

      ..(If you disagree, ask yourself how many hands you have, for instance. Is it one or two?)..

      Oh! I disagree!, because I have just one hand! But humans should have two! You see? :)

      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