Be careful with your expectations, as your results will actually be;
1 4
2 4
3 4
Even though the first two lines have nothing after the last "|" there will still be a count of 4 for each line - even for an empty field. You will need to manage that by either not adding the trailing "|" or checking for "relevant content" of each field. Something like, if a field = /^$/ then take 1 away from the value of NF.
If you have a consistent number of "|" then your NF will always be the same regardless of what is between them.