for my $opt ( qw/user_name password input_file/ ) { next if ( $opthash{$opt} ); print "You need to specify a $opt: " if ( $opt eq "password" ) { ReadMode( "noecho" ); else { ReadMode( "normal" ); } $opthash{$opt} = ReadLine(0); ReadMode( "restore" ); die "You really should have typed something for $opt\n" unless ( $opthash{$opt} ); } # this input mechanism only needs to be written once