Похоже, что ERRORLEVEL не является истинным кодом выхода для perl.
У меня та же проблема.Файл bat
@Echo OFF
echo setting error level 1
EXIT /B 1
С файлом perl
#!/usr/bin/perl
$command = `C:\foo.bat`;
print "Error Level: " .$? ."\n";
print "Command: " . $command . "\n";
Выходные данные
Error Level: 0
Command:
Файл perl
#!/usr/bin/perl
my $command = `dir`;#try both dir and dri to test real exit codes against batch exit codes
print "Error Level: " .$? ."\n";
print "Command: " . $command . "\n";
даст
C:\>back.pl
'dri' is not recognized as an internal or external command,
operable program or batch file.
Error Level: 256
Command:
C:\>back.pl
Error Level: 0
Command: Volume in drive C has no label.
Volume Serial Number is 8068-BE74
Directory of C:\
12/13/2010 11:02 AM 7 8
06/02/2010 01:13 PM 0 AUTOEXEC.BAT
06/04/2010 01:00 PM <DIR> AutoSGN
12/13/2010 12:03 PM 111 back.pl
06/02/2010 01:13 PM 0 CONFIG.SYS
06/03/2010 07:37 PM <DIR> Documents and Settings
12/13/2010 12:01 PM 46 foo.bat
06/04/2010 03:17 PM <DIR> HorizonTemp
06/02/2010 02:41 PM <DIR> Intel
06/04/2010 02:19 PM <DIR> league
06/04/2010 12:31 PM <DIR> Perl
12/10/2010 03:28 PM <DIR> Program Files
12/08/2010 04:13 PM <DIR> Quarantine
12/13/2010 08:14 AM <DIR> WINDOWS
5 File(s) 164 bytes
9 Dir(s) 18,949,783,552 bytes free
C:\>