Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Perl : Split/Regex

by 2teez (Vicar)
on Sep 03, 2014 at 23:19 UTC ( [id://1099486]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1099486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found