in reply to Re^2: Double your return!!!!
in thread Double your return!!!!

okay, i don't consider my self very 'leet, but - just to defend my honor (my parents could read this someday! :-), i DO know and.
that one doesn't really help a lot, because then my whole script would consist of a gigantic concatenation of and clauses.
besides - mea maxima culpa - i actually do stuff in between my user interaction things, so that one wouldn't work (should've showed that, though)

thanks for the tip, though!

by the way: what is the voting etiquette for situations like this? if i were an even bloodier newbie than i am, this one would have helped, and it's really nice of you to help me this way - OTOH, it didn't really help ME, and is a rather...ermm..."banal" thing (really no offense!).
i'll ++ it, but i was just wondering how "valuable" votes are....

kali nixta kai evxaristo
(pardon the horrific ASCII-sation :-)

Replies are listed 'Best First'.
Re^4: Double your return!!!!
by Aristotle (Chancellor) on Feb 19, 2003 at 11:23 UTC
    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.

      i really liked the last approach - thanks.