return undef unless defined $name = askFor(title => 'Name:');
# do stuff with $name
return undef unless defined $cigs = askFor(title => 'Cigarettes:');
# do stuff with $cigs
# ...
####
sub askFor {
# ...
die if $pressed_cancel;
# ...
}
# ...
eval {
$name = askFor(title => 'Name:');
# do stuff with $name
$cigs = askFor(title => 'Cigarettes:');
# do stuff with $cigs
}
####
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