my $SAVE_PLACE; GetOptions( 's|save_to:s' => \$SAVE_PLACE, ); # here the value of $SAVE_PLACE will be: # undef if no -s --save_to # 0 if -s --save_to but no optional argument # if -s= while ( defined $SAVE_PLACE and not $SAVE_PLACE ) { $SAVE_PLACE = prompt("Save to where: "); } sub prompt { print @_; chomp(my $ans = <>); $ans }