in reply to Problem with the Perl/Java intergarion when new line break is used in the argument

I also know nothing about Java. But, it looks like the Java "exec" is not treating the "\n" as a newline character. Or maybe the double quotes in Java are performing some type of interpolation. Does Java have any non-interpolation quotes, like single quotes (q) in Perl?

As a (lame) workaround, since you are performing a substitution on "\n" in your perl code, maybe you could use a different delimiter, like ":"

Process p = Runtime.getRuntime().exec("c:/perl.exe" C:/CreateER.pl "P +lease : ignore : my friend");

then:

s/:/\n/g;

Update: As an aside, your code spews a warning if you add use warnings; (verbose explanation provided by use diagnostics;):

Scalar value @ARGV[1] better written as $ARGV[1] at ... (W syntax) You've used an array slice (indicated by @) to select a single element of an array. Generally it's better to ask for a sc +alar value (indicated by $). The difference is that $foo[&bar] always behaves like a scalar, both when assigning to it and when evaluati +ng its argument, while @foo[&bar] behaves like a list when you assign to +it, and provides a list context to its subscript, which can do weird t +hings if you're expecting only one subscript. On the other hand, if you were actually hoping to treat the array element as a list, you need to look into how references work, beca +use Perl will not magically convert between scalars and lists for you. + See perlref.
  • Comment on Re: Problem with the Perl/Java intergarion when new line break is used in the argument
  • Select or Download Code