Larry Wall wrote :
> 
> Paragraph mode is not going away--it's merely going elsewhere.  :-)
> 
>: If so, what's the rationale?  Another case of "you can't do it right
>: internationally, so better not to do it at all"?
> 
> No, it's simply that using a global variable to control something
> that should be a filehandle attribute is the wrong way to go about it.

The readline function takes an input filehandle and a line separator and
returns a line. So it makes sense to store the line separator in the
filehandle. OK.

>: I'm just looking at the huge number of stanza-based files and
>: system-utility output sysadmins deal with every day using C<$/ = ''>, and
>: thinking "yeah, I could just write a grammar, but it's just a simple regex
>: match in paragraph mode..."
> 
> No problem, you'll just say something like:
> 
>     $fh = open $filename, ":para";
>     for <$fh> -> $para { ... }
> 
> Eventually the Perl 5 folks will get around to implementing such
> user-oriented layers in Perl 5, but at the moment they're still working
> on the encoding-oriented layers, which is fine.

This seems to be a weird way to specify the line separator.

What if you stack many of them ?
    $fh = open $filename, ":para:slurp";
    $fh = open $filename, ":slurp:para";
    $fh = open $filename, ":para:chunk(8192)";
        # (assumming that :chunk does the job of $/ = \8192)

or, worse, if you mix them with encoding layers ?
    $fh = open $filename, ":lineending(\n):crlf";
    $fh = open $filename, ":crlf:lineending(\n)"; # will I get \r chars ?

Encoding layers know nothing about end-of-line terminators. I'm under
the impression that encoding layers and user layers have different
semantics : respectively buffer filters and user-space modifiers.
(Another example of a user layer could be :taint to taint/untaint the
data read from the filehandle. That's something that modifies a
filehandle's attribute, but that doesn't affect the way the data is
read/written and encoded.)

Oh, and $\ should become a filehandle attribute too.
    $fh = open $filename, ">:lineending(\n)";
    $fh = open $filename, ">:lineending(\n):gzip";
    $fh = open $filename, ">:gzip:lineending(\n)"; # ???

Reply via email to