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

Re: RFC? pre-RFC? Return of the Jedi^W err/dor

Thread Previous | Thread Next
H.Merijn Brand
August 11, 2021 15:28
Re: RFC? pre-RFC? Return of the Jedi^W err/dor
Message ID:
On Wed, 11 Aug 2021 10:41:58 -0400, James E Keenan <>

> Since the last time this came up was several years ago, would it be
> possible to provide a one-paragraph explanation for the rationale for
> the feature?

Consistency.  Essentially, when // was introduced, the low-level
operator was forgotten.

In my life as perl user I have never ever needed or used xor, but I
have used err while it was defined many many times. It is about making
easy (but ugly) things even easier and more consistent.

Low-level precedence operators enable coders to use less line noise.

  foreach my $value (get_values ($foo)) {
      my $v = convert_value ($value) dor next; # "" and 0 are ok
      # ...

  sub foo {
      my $v = shift dor return;
      # ...

There are two camps in using and/if or/unless

 warn "Blah" if $error;
 $error and warn "Blah";

I am *firmly* in the second, as that fits how I think.

I also am a strong proponent of using early return instead of the (in
my perception very stupid) only-one-return.

 sub foo {
     if (defined $foo) {
         # 50 lines of code
     else {
         die "foo was not defined";


 sub foo {
     defined $foo or return;

     # 50 lines of code

with dor next to and and or, the code stay clean, readable,
maintainable and more consistent. In the if/else example I would
not care, as the code already looks like a mess (to me).

H.Merijn Brand   Perl Monger
using perl5.00307 .. 5.33        porting perl5 on HP-UX, AIX, and Linux

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