Код OP идеален двойные кавычки случай неправильного использования, use strict
и use warnings
будут сигнализировать о потенциальной проблеме
use strict;
use warnings;
use feature 'say';
print "Content-Type: text/html\n\n";
my @args = ("java", "-jar", "C:\Users\RajendraPrasadH\eclipseworkspace\ApplicationProtector\target\ApplicationProtector-0.0.1-SNAPSHOT.jar");
say for @args;
Выход
Unrecognized escape \R passed through at misuse_double_quote_1.pl line 6.
Unrecognized escape \A passed through at misuse_double_quote_1.pl line 6.
Unrecognized escape \A passed through at misuse_double_quote_1.pl line 6.
Content-Type: text/html
java
-jar
C:SERSRAJENDRAPRASADHCLIPSEWORKSPACEAPPLICATIONPROTECTOR ARGETAPPLICATIONPROTECTOR-0.0.1-SNAPSHOT.JAR
Perl интерпретатор выполнил интерполяцию строки в двойных кавычках путем расширения backsha sh sequence .
Правильный код для @args = ('...','...','...')
use strict;
use warnings;
use feature 'say';
print "Content-Type: text/html\n\n";
my @args = ('java', '-jar', 'C:\Users\RajendraPrasadH\eclipseworkspace\ApplicationProtector\target\ApplicationProtector-0.0.1-SNAPSHOT.jar');
say for @args;
Вывод
Content-Type: text/html
java
-jar
C:\Users\RajendraPrasadH\eclipseworkspace\ApplicationProtector\target\ApplicationProtector-0.0.1-SNAPSHOT.jar
Более естественным способом было бы написать код как
use strict;
use warnings;
use feature 'say';
say "Content-Type: text/html\n";
my @args = qw/java -jar C:\Users\RajendraPrasadH\eclipseworkspace\ApplicationProtector\target\ApplicationProtector-0.0.1-SNAPSHOT.jar/;
say for @args;
system(@args);
Вывод
Content-Type: text/html
java
-jar
C:\Users\RajendraPrasadH\eclipseworkspace\ApplicationProtector\target\ApplicationProtector-0.0.1-SNAPSHOT.jar