I need the retrieve the output of a Java program and store it in a Perl variable so that i'll be able to use split function. I am getting the java output using,
my @args = ("java", "-jar", "first.jar");
system(@args);
But how to convert this @args into $args variable (string) so that i can split the output from the string.
I hope you need to store the output of the jar file. So use backtick instead of system.
Try to know difference between
system and Backtick / qx
my @args = ("java", "-jar", "first.jar");
my $result = `@args`;
my @ans = split(" ",$result);
print "$ans[0] $ans[1]";
suppose your result is xyz abc. $ans[0] store the xyz and $ans[1] store the abc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With