in reply to -F and trailing empty fields

Ok, I don't think it's the '-F' option after looking at this, it seems that my use of the '-l' option in conjunction with -F/-a is causing the trailing fields to drop off. For example, when I do:
perl -F, -lane 'print join("!",@F)' test.txt
I lose the trailing empty fields. But, removing the '-l' option returns them:
perl -F, -ane 'print join("!",@F)' test.txt
Does anyone understand why this is happening? According to the command line help and perldoc -l without a parameter enables line ending processing, chomping the input line and setting $\ (output separator) equal to $/ (input separator). Why would that cause the -F splitting to drop the empty, trailing characters?

---
s;;:<).>|\;\;_>?\\^0<|=!]=,|{\$/.'>|<?.|/"&?=#!>%\$|#/\$%{};;y;,'} -/:-@[-`{-};,'}`-{/" -;;s;;$_;see;
Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.

Replies are listed 'Best First'.
Re^2: -F and trailing empty fields
by tuxz0r (Pilgrim) on Apr 30, 2008 at 18:06 UTC
    Is it that the "newline" after the last comma (essentially empty) is seen by split (-F) to be a value in that field, and hence it retains it and any preceding empty fields? Because if the input is line such as a,,,, I only get the 'a' on output (using -l with -F/-a), but if it's ,,,,,a I get all the fields. Is that normal behavior to have split assume the newline at the end of a character separated record is part of the value for that field (even if $/ is '\n')?

    ---
    s;;:<).>|\;\;_>?\\^0<|=!]=,|{\$/.'>|<?.|/"&?=#!>%\$|#/\$%{};;y;,'} -/:-@[-`{-};,'}`-{/" -;;s;;$_;see;
    Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.