develooper Front page | perl.perl6.language | Postings from May 2005

Re: Question on "is chomped"

Thread Previous
Larry Wall
May 12, 2005 21:11
Re: Question on "is chomped"
Message ID:
On Thu, May 12, 2005 at 02:52:01PM -0400, Joshua Gatcomb wrote:
: While E02 states that "is chomped" sets the chomped property of
: afilehandle, I didn't find any detailed specifications in any of the
: As or Ss.
: So - is "is chomped" always the equivalent of:
: while ( <FH> ) {
:     chomp;
: }
: For instance - you have opened the file rw
: Or, the idea of having mutator and non-mutator versions of chomp (and
: other functions) have been kicked around the list.
: Any definitive word yet?

There isn't really an "is chomped".  If you set the line terminator
for a filehandle, it marks the input strings as to where it thinks
the the line should be chomped (which can vary from line to line).
Then you can either add an autochomp to the filehandle to automatically
remove that, or a subsequent call to ordinary chomp() removes that
sequence.  If a line is not marked by an input layer, then chomp()
will presumably try to remove any standard line terminator.

In early Perl it was important to leave the newline on and chop/chomp
it later as a separate operation, but that's because of use of
while(<>) for input (at least until we snuck in the definedness hack).
In Perl 6 we're switching everyone to for =<> instead, which does
not depend on whether =<> returns a true/defined value, but only on
whether the generator has run out, so it's perfectly fine for the
input layer to autochop boring line terminators for you.  It's really
only if you're interested in varying line terminators that you would
want to do your own chomp.

I call it "autochomp" on a handle, but it's probably just :chomp or
some such.  We really haven't worked out how the IO layers interact
yet, or what their arguments are.  Almost need a perl6-io list
to work all that out...


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About