in reply to In-place search and replace confined to a specific column

As Discipulus pointed out, using both -p and -n doesn't make much sense. And you'll have to use the correct operator as Corion told you

Your issue is that -p prints $_ no matter what, it doesn't print back the splitted data of @F. You have to do that yourself: $" = qq(\t);$_="@F"; You'll find $" in perlvar.

Edit: you can try this to see the code that perl generates from your one liner: perl -MO=Deparse -pae '$_ = @F'

LINE: while (defined($_ = <ARGV>)) { our(@F) = split(' ', $_, 0); $_ = @F; } continue { die "-p destination: $!\n" unless print $_; }

Edit: replaced $"="\t"; by  $" = qq(\t); because the first one looked like a syntax error.

Replies are listed 'Best First'.
Re^2: In-place search and replace confined to a specific column
by Discipulus (Canon) on Jan 29, 2016 at 11:40 UTC
    Brava Eily!

    never tought to use -MO=Deparse to inspect a oneliner! this trick push me even more up in the dark oneliner side of the source..

    Anyway -p seems to superseed -n in both order, results are equal:

    perl -MO=Deparse -p -n -e 1 LINE: while (defined($_ = <ARGV>)) { '???'; } continue { die "-p destination: $!\n" unless print $_; } -e syntax OK perl -MO=Deparse -n -p -e 1 LINE: while (defined($_ = <ARGV>)) { '???'; } continue { die "-p destination: $!\n" unless print $_; } -e syntax OK'

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.