develooper Front page | perl.perl5.porters | Postings from April 2009

Exiting given/when via next/last/redo

From:
Ben Morrow
Date:
April 23, 2009 19:19
Subject:
Exiting given/when via next/last/redo
Message ID:
20090424021859.GA69302@osiris.mauzo.dyndns.org
I'm puzzled by this warning:

    ~% perl -wE'LOOP: for (1..2) { when (1) { next LOOP } }'
    Exiting when via next at -e line 1.

Since given/when is an if-like construct, and there's no potential
confusion about where the flow of control is going, is a warning really
necessary? Also, this

    perl -wE'for (1..2) { when (1) { say; last } }'

doesn't warn, even though this

    perl -wE'sub foo { last } for (1..2) { say; foo } }'

does.

Ben




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