The multiple functions are probably overkill for this, but in general this looks decent. (I'd use a while loop instead of a do { } unless, but that is partly taste.)
'$flag' isn't a global variable (conceptually): it's a flag variable who's scope includes the while loop it controls. The fact that in this case that means it is at the top-level scope isn't really relevant. The only real way to write this without the variable would be to have do_it be in the loop condition itself, and that's more ugly. (And less expandable.)
I'd be tempted to rename '$flag' to '$again': Then do_it returns whether we want to do it again. But that's just me reading it and having fun. ;)
Oh, and this:
my $drink = shift; my $positions_ref = shift; my $locations_ref = shift;
Can be shortened to this:
my ($drink, $positions_ref, $locations_ref) = @_;
In reply to Re: Repeating an input prompt
by DStaal
in thread Repeating an input prompt
by zod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |