You could still do something like
return undef unless defined $name = askFor(title => 'Name:'); # do stuff with $name return undef unless defined $cigs = askFor(title => 'Cigarettes:'); # do stuff with $cigs # ...
That would at least reduce your two statements to a single one. If you really insist on a "double return" you need to do something like this:
sub askFor { # ... die if $pressed_cancel; # ... } # ... eval { $name = askFor(title => 'Name:'); # do stuff with $name $cigs = askFor(title => 'Cigarettes:'); # do stuff with $cigs }
which, incidentally, is really the standard idiom for such cases (think DBI). Another option might be to change your askFor() so that it assigns the result itself and returns whether or not it succeeded:
sub askFor { # ... return if $pressed_cancel; ${$arg{Var}} = $user_input; } # ... return unless askFor(title => 'Name:', Var => \$name); # do stuff with $name return unless askFor(title => 'Cigarettes:', Var => \$cigs); # do stuff with $cigs

Plenty of ways to do what you want, really.

Oh, and about the voting - don't sweat it. Who cares.

Makeshifts last the longest.


In reply to Re^4: Double your return!!!! by Aristotle
in thread Double your return!!!! by bsb

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.