in reply to returning to a loop later on

{1} is redundant in a regex - always.

Your indentation is stuffed. It looks like the first if is inside the first while loop - it isn't.

redo FILENAME doesn't have a matching loop.

You could structure your code something like:

while (1) { while ($out !~ m/^[sSfF]$/) { ... } if ($out =~ m/^[sS]$/) { print $output; next; } last; } exit if $out !~ m/^[fF]$/; while (1) { while ($save !~ (m/^[a-zA-Z]\w*$/)) { ... } if (-e $save) { ... } if ($overwrite =~ m/^[nN]$/) { next; } ... last; }

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: returning to a loop later on
by mreece (Friar) on Sep 07, 2006 at 03:40 UTC
    redo FILENAME doesn't have a matching loop.
    it doesn't have to be a loop, you can label blocks, too!
    my $i = 0; FOO: { print "$i\n"; redo FOO unless ++$i > 4; }

      Indeed, but you can't redo to a label that is not in labling the current scope:

      FOO: { # scope 1 { # scope 2 redo FOO; # Ok } redo FOO; # Ok } { # scope 3 redo FOO; # Illegal }

      Prints:


      DWIM is Perl's answer to Gödel
        you can't do that with a loop, either, right? perhaps i am misunderstanding you, but that is not the situation with the OP's code, imperfect as it may be; the redo FILENAME is within the FILENAME: { }