in reply to Nested OR as a control structure

Others have pointed out better ways of doing this; for the record I'll just explain how Perl was seeing your code. Perl expects an expression to follow 'or', so
... or { ....; ... }
is interpreted as an anonymous hash constructor, and the semicolon in the middle of it is then a syntax error. Also, no-one seems to have mentioned 'do'; this allows you to use a block of code as an expression, eg
.... or do { statement; statment; statement_with_final_value }
But most of the time you're still better off using if/else.

Dave.

Replies are listed 'Best First'.
Re^2: Nested OR as a control structure
by simonm (Vicar) on Jun 03, 2004 at 17:27 UTC
    Also, no-one seems to have mentioned 'do'...

    Yup, that's what I was thinking.

    I've become increasingly fond of the do-block syntax; here's the OP's code with the two "do"s added where needed:

    unless ($dontdothis) { dofistcritical() or do { dobackupcritical() or do { die "main and backup failed"; }; dobackupremainder(); exit 0; }; dofirstremainder(); exit 0; }