我有run.pl和decrypt.pm错误在Perl
run.pl处理:
my $secret2 = "test password";
my $ret=decrypt::decodeIt($secret2);
print $ret;
decrypt.pm:
sub decodeIt {
$tmp="";
.........
.........
.........
return $tmp
}
我打电话decodeIt()子中run.pl.但是在decodeIt sub和run.pl引发错误时出了点问题。我不希望看到这些错误异常被打印在屏幕上,我想捕获run.pl中的错误,并在下面有错误时执行其他操作。我尝试像下面但不能捕获错误。
if(!decrypt::decodeIt($secret2)){
print "Error in decode";
} else {
my $ret=decrypt::decodeIt($secret2);
print "No Error :".$ret;
}
现在我在屏幕上看到的错误是;
Argument "te" isn't numeric in int at decrypt.pm line 61.
Illegal hexadecimal digit 's' ignored at decrypt.pm line 64.
Illegal hexadecimal digit ' ' ignored at decrypt.pm line 64.
Illegal hexadecimal digit 's' ignored at decrypt.pm line 64.
Illegal hexadecimal digit 's' ignored at decrypt.pm line 64.
Illegal hexadecimal digit 'o' ignored at decrypt.pm line 64.
substr outside of string at decrypt.pm line 68.
Use of uninitialized value $string in length at decrypt.pm line 69.
我不想在屏幕上看到这些错误。我只想了解是否有错误,并在出现错误时采取一些措施。
错误在'decrypt.pm'。在第61行,我们需要看61-70行可以回答什么。 – Sobrique
我不想防止错误。有错误是可以的。我在decrypt.pm的子程序中故意创建错误。我只想处理run.pl中的错误,我称之为子程序。 – ivbtar