develooper Front page | perl.perl5.porters | Postings from October 2021

Re: Pre-RFC: command-line flag for slurping

Thread Previous | Thread Next
From:
Vlado Keselj
Date:
October 1, 2021 14:24
Subject:
Re: Pre-RFC: command-line flag for slurping
Message ID:
alpine.LFD.2.20.2110011119340.30603@tr

I agree that the "slurp" operation is important, but I would argue that it 
is more important in code than globally defined by a flag.  The flag is 
fine, but is there a recommended way to "slurp" a file.  I usually use:
$_ = join('',<>); since it is easy to remember, and use a short custom 
made function getfile($filename) for slurping files.  It would be nice to 
have a recommended way to "slurp" in-line as well as having a flag.

On Fri, 1 Oct 2021, Yuki Kimoto wrote:

> 
> 
> 2021-9-30 0:00 Tomasz Konojacki <me@xenu.pl> wrote:
>       "-0777" flag is the usual way to read the whole file at once (instead of
>       line by line) in one-liners.
> 
>       I feel this isn't ideal. "-0" is a bad flag. It's overly general, users
>       rarely need $/ to be set to anything other than undef or "\n". Also, the
>       input record separator has to be specified as an octal number, which is
>       weird. The fact that the numbers above 0o377 are special-cased to mean
>       "undef" makes it even more confusing.
> 
>       Slurping is an extremely common operation and it deserves its own
>       one-letter flag. I propse "-g" (mnemonics: gobble, grab, gulp). I wish
>       it could be "-s", but sadly it's already taken :(
> 
> 
> 
> I feel  slurping is a very general operation in this age.
> 
> For example, HTML.
> 
> HTML is not a line to line protocol. the whole file needs to be parsed by regular expression.
> 
>   <h1>
>      Foo
>   </h1>
> 
> And the available memory is large enough.
> 
> 
> 
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About