my $sshport; while ( $sshport !~ /^[1-9]\d+$/ || $sshport > 65535 ) { print " Please Enter valid ssh port number:\n"; chomp( $sshport = ); }