I personally believe that when 5.10's new -E switch is used in conjunction with -n, it should turn on autochomping similar to what -l does with both -n and -p. With -E in fact, one has say() which is precisely equivalent to -l's print(). (Unless one changes $\ that is.) Furthermore, -E enables all optional features which in turn import some Perl 6-ish syntax in Perl 5, and Perl 6 has autochomping on by default.

--
If you can't understand the incipit, then please check the IPB Campaign.

Replies are listed 'Best First'.
Re: How 'bout autochomp on for -nE?
by moritz (Cardinal) on Jun 03, 2008 at 19:22 UTC
    Is autochomp implemented in some way in perl 5.10 in some way? If not, that's the first place to begin with. When it's implemented, we can start to talk about default behaviour.

    Anyway, I like the idea.

      Is autochomp implemented in some way in perl 5.10 in some way?

      As I wrote, the only autchomp I know of in Perl 5 takes place as a consequence of the joint action of the -l and -n (or -p) switches:

      C:\temp>perl -MO=Deparse -lne "" BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = <ARGV>)) { chomp $_; }

      I thought that -nE, in addition to enabling all optional features, may similarly do:

      C:\temp>perl -MO=Deparse -nE "" LINE: while (defined($_ = <ARGV>)) { chomp $_; } -e syntax OK

      (Note: this is not the actual output; I hand edited it.)

      --
      If you can't understand the incipit, then please check the IPB Campaign.

        So -lnE is that much harder to type than -nE ? What is somebody supposed to do if they want -nE w/o autochomp? Seems like a patch to make an alias to perl as just "p" would be 3x as effective and apply even in cases when -E wasn't used (and, more importantly, it wouldn't disable the ability to get -nE w/o autochomp), so do that instead.

        It would make more sense to change -lnE to only enable autochomp, not set $\ (since say can be used).

        - tye