in reply to Re: How 'bout autochomp on for -nE?
in thread How 'bout autochomp on for -nE?

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.

Replies are listed 'Best First'.
Re^3: How 'bout autochomp on for -nE? (Re:-p)
by tye (Sage) on Jun 04, 2008 at 03:42 UTC

    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        

      I mostly agree. I think -E shouldn't enable autochomp. Otoh for this

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

      I'm still not sure. What about -lpE? Would that print a newline? What about -l0 -pE or -l0999 -pE or any other separator? Say doesn't work for those, so you have to set $\.
      It would make more sense to change -lnE to only enable autochomp, not set $\ (since say can be used).

      I was about to answer to your first point to the effect that one would have both print() and say() doing the same thing which makes for some less expressive power than leaving $\ untouched, but then you thought of this yourself, and ultimately I fully second your suggestion.

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