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

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

Thread Previous | Thread Next
From:
Smylers
Date:
September 30, 2021 08:19
Subject:
Re: Pre-RFC: command-line flag for slurping
Message ID:
20210930081905.GO3848@stripey.com
Tomasz Konojacki writes:

> "-0777" flag is the usual way to read the whole file at once in
> one-liners.
> 
> Slurping is an extremely common operation and it deserves its own
> one-letter flag. I propse "-g" (mnemonics: gobble, grab, gulp).

Yes, please. I have taught Perl for a living, and having a single option
for this would making teaching one-liners much easier.

The current -0 option has the flexibility of being completely general,
but that generality gets in the way of learning the most common cases:
you need to understand the concepts of record separators, octal, and
then a non-octal token.

There are now several messages of support and none against, so I think
you may now proceed to writing and submitting an RFC.

Oodler 577 via perl5-porters writes:

> If it's going to be equivalent to "-0777", which directly impacts the
> record separator, then "-R" is probably better.

One of the advantages I see of such a flag is *not* needing to think
about it at the level of the record separator (unless you want to). The
flag would cause Perl to read in a whole file/all of standard input at
once. That it would do this by setting the input record separator to a
specific value is *how* it does that, but not *why* you would use the
flag.

> Then again, the general move towards long opts

It sounds like there are many in favour of long options. An RFC on that
matter may be worthwhile.

But that isn't a reason to delay *this* RFC for something else which may
or may not happen.

Smylers



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