in reply to Re (tilly) 2: Yet another one-liner
in thread Yet another one-liner

tilly, your version:

perl -pi.bak -e 'BEGIN{$/=$u}s//\n/' foo*

Works fine with 5.00503, but with 5.6.0 it appends an extra newline to the file:

$ cat > XXX 1 2 3 $ cp XXX fxx $ perl5.00503 -pi.bak -e 'BEGIN{$/=$u}s/^/\n/' fxx* $ cat fxx 1 2 3 $ cp XXX fxx $ perl5.6.0 -pi.bak -e 'BEGIN{$/=$u}s/^/\n/' fxx* $ cat fxx 1 2 3 $

Curious.

Replies are listed 'Best First'.
Re (tilly) 4 (BUG!): Yet another one-liner
by tilly (Archbishop) on Jan 12, 2001 at 06:43 UTC
    This is clearly a bug. According to perlrun it is supposed to be equivalent to the following loop:
    perl -i.bak -e 'BEGIN{undef $/;} while (<>) { s//\n/; print }' foo*
    but the latter is working for me on 5.6.0 and in a recent snapshot, while the former fails for me as well.

    I believe that this is a real bug.

    UPDATE
    The plot thickens. I saw your bug in both 5.6.0 and in a recent development snapshot. Turns out I had only tested the fixed version in a recent snapshot and in the original Perl. It is broken in 5.6.0 for me as well.

    However none were broken for Lexicon on NT running binary build 618 from ActiveState. It probably doesn't matter that he was running on a Japanese version of NT.