in reply to Re^2: What's the point of a labeled block without a loop?
in thread What's the point of a labeled block without a loop?

The only real benefit is reader clarity. By labelling it, you're giving a reason for a bare-block.

Also, my personal style - I (mostly) always put a label with every last and redo. (I don't for next because next is much more common.)


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re^3: What's the point of a labeled block without a loop?

Replies are listed 'Best First'.
Re^4: What's the point of a labeled block without a loop?
by Hue-Bond (Priest) on Dec 17, 2005 at 12:43 UTC
    By labelling it, you're giving a reason for a bare-block.

    In this specific case, it can be done without a bare block:

    my $age; do { print "Please enter your age: "; chomp ($age = <STDIN>); } while $age =~ /\D/; print "Got it: $age\n"; __END__ Please enter your age: hi there Please enter your age: 123abc Please enter your age: 99 Got it: 99

    --
    David Serrano

Re^4: What's the point of a labeled block without a loop?
by Perl Mouse (Chaplain) on Dec 18, 2005 at 14:11 UTC
    By labelling it, you're giving a reason for a bare-block.
    Huh? Do you really mean to say that the label is the reason for the bare block?
    Perl --((8:>*