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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.