develooper Front page | perl.perl5.porters | Postings from July 2020

Re: RFC: LEAVE phasers

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
July 3, 2020 21:49
Subject:
Re: RFC: LEAVE phasers
Message ID:
20200703224928.4e695eae@shy.leonerd.org.uk
On Sun, 28 Jun 2020 03:35:38 +0200
Branislav ZahradnĂ­k <happy.barney@gmail.com> wrote:

> How will LEAVE and continue to work together?

A fun question. I have to say I don't think I've ever used a `continue`
block and I'd forgotten they exist, but yes they definitely should be
considered here.

I suspect it would probably work something like the following:

  use v5.10;
  foreach my $x (1, 2) {
    say "Doing $x";
    LEAVE { say "Did $x"; }
  } continue {
    say "Continuing after $x";
    LEAVE { say "Continued after $x"; }
  }


  Doing 1
  Did 1
  Continuing after 1
  Continued after 1
  Doing 2
  Did 2
  Continuing after 2
  Continued after 2

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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