I'm parsing a pipe delimited file and working my way through each element with foreach after splitting each line. What I'm finding is that uninterrupted empty fields to the end of the line are being somehow skipped for processing, i.e.:
# input example: 1|2|3|||6|7|||| @fields = split('\|', $_); foreach (@fields) { &process($_); } sub process { print $_ . "\n"; }
In this case the empty elements after "7" will not be printed. However, if I were to fill the last empty element with a value, all the empty elements in between will be printed. Any thoughts? Thanks in advance.
In reply to foreach skipping elements by tiggyboo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |