in reply to Re^2: GOTO or not GOTO
in thread GOTO or not GOTO

I'd write that as (untested)
while ( uninteresting() ) {}; : : sub uninteresting { # I assume $file and $max_tries are globals my $url = ask_url(); my $status = getstore($url, $file); return ( $status == 200 && !-s $file && --$max_tries > 0 ); }

Replies are listed 'Best First'.
Re^4: GOTO or not GOTO
by JavaFan (Canon) on Jan 27, 2009 at 12:16 UTC
    Well, neither $file nor $max_tries are globals. During the live time of the program the routine is called hundreds of times, and for each new call, I've a new file name, and 10 new tries. Besides, isn't using global variables a sin as bad as a goto?

    But more importantly, the reason I wrote the code with the goto is that I need the $status afterwards. And I need to know whether the download eventually succeeded or not. Now, you can achieve all that by having uninteresting returning a list of two things (the status code, and whether it succeeded or not), but the code gets more complex that way.

    I prefer the simplicity of the goto solution.