我一直在查看我的代码,但我无法弄清楚以下错误在哪里:uninitialized value $match in string eq perl
基本上,代码通过 TELNET 连接到多个设备并关闭连接。它只是测试用户及其密码以查看哪些已过期。当它连接时给出成功消息,否则给出失败消息。
我不知道为什么它会给我那个未初始化的值错误。这是我用于我的项目的代码:
$telnet = new Net::Telnet (
Errmode => "return",
Port => $puerto,
Input_log => $output_log,
Host => $host
);
$conexion = $telnet -> open(Timeout => 5);
if ($conexion == 1) {
print "Se conecto al $host \n\n";
$input = $telnet -> get(Timeout => 10);
if ($input) {
if ($input =~ /login name:/){
$cmd = $telnet -> print($user);
($prematch, $match) = $telnet -> waitfor(
Timeout => 5,
Match => '/password:/');
if ($match) {
$cmd = $telnet -> print($password);
($prematch, $match) = $telnet -> waitfor(
Timeout => 5,
Match => '/Windows/');
if ($match) {
$cmd = $telnet -> print("");
($prematch, $match) = $telnet -> waitfor(
Timeout => 5,
Match => '/choose/');
# Aca se tiene que diseñar el caso de errores de clave
//////ERROR LINE//////
if ($match eq "choose") {
//////ERROR LINE//////
$cmd = $telnet -> print("2");
($prematch, $match) = $telnet -> waitfor(
Timeout => 5,
Match => '/Corp/');
if ($match) {
print "Se autentico satisfactoriamente el usuario y la contrasena\n\n";
}
} else {
print "el usuario o contrasena son erroneos, fallo la conexion\n\n";
$cerrar = $telnet -> close;
}
}
}
}
}
}
$cerrar = $telnet -> close;
}