in reply to Re^3: while(){}continue{}; Useful? (Consistent!)
in thread while(){}continue{}; Useful?

> This produces identical results, and IMO is far clearer and more intuative:

Not with multiple nexts and code in between. Your more intuitive approach will result in nesting unless blocks for each next, instead of (mostly) linear code.

Cheers Rolf

Replies are listed 'Best First'.
Re^5: while(){}continue{}; Useful? (Consistent!)
by BrowserUk (Patriarch) on Mar 04, 2010 at 01:16 UTC

    No nesting required?

    LINE: while ( <STDIN> ) { unless( /^#/ # its a comment or /^$/ # or blank line ) { ... ## do whatever } $count++; ## and count them all }

    Update: Darn! Wrong place!


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      > > > This produces identical results, and IMO is far clearer and more intuative:

      > > Not with multiple nexts and code in between.

      underlines added!

      UPDATE: Think of it like a switch statement with a fall through to the continue block.

      Cheers Rolf