in reply to -F and trailing empty fields

Split uses $_ as its default argument and delivers its data into @_ unless assigned so:

C:\>type test.txt a,b,c,d,e,f a,,c,,e, a,b,c,,, C:\>perl -pe "split/,/;$_=join'!',@_" test.txt a!b!c!d!e!f a!!c!!e! a!b!c!!!

Yours is longer but to be fair if I golf it down it works out exactly the same number of characters, however this does as you want, except @F is @_. It looks like dropping the empty fields is an apparently undocumented feature.

Replies are listed 'Best First'.
Re^2: -F and trailing empty fields
by KurtSchwind (Chaplain) on Apr 30, 2008 at 17:33 UTC

    Maybe this is a quoting thing but on my linux box:

    ~/src> perl -pe "split',';$_=join',',@_" smoke.txt Can't modify concatenation (.) or string in scalar assignment at -e li +ne 1, at EOF Execution of -e aborted due to compilation errors.
    --
    I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.

      It is a quoting thing. On *nix s/'/tmp/g; s/"/'/g; s/tmp/"/g :-)

      perl -pe 'split/,/;$_=join",",@_' smoke.txt