Re: Using java Strings from within perl

2005-09-23 Thread Jason Stelzer
Patrick LeBoutillier wrote: >Jason, > >I see what's going on. The problem is that a byte in Perl has range >0-255, but a byte in Java has range -128-127. That's why Inline::Java >is telling you that the values you are passing are out of range. > >Inline::Java should probably do this kind of conver

Re: Using java Strings from within perl

2005-09-23 Thread Patrick LeBoutillier
Jason, I see what's going on. The problem is that a byte in Perl has range 0-255, but a byte in Java has range -128-127. That's why Inline::Java is telling you that the values you are passing are out of range. Inline::Java should probably do this kind of conversion automatically for you, but for

Re: Using java Strings from within perl

2005-09-22 Thread Jason Stelzer
On Sep 22, 2005, at 8:40 PM, Patrick LeBoutillier wrote: Jason, Have you tried something like this: I have. I've attached some very similar code that I've tried just to get things working. I agree that splitting a (potentially large) string into bytes is expensive, but if that works I'l

Re: Using java Strings from within perl

2005-09-22 Thread Patrick LeBoutillier
Jason, Have you tried something like this: use strict ; use warnings ; use Inline ( Java => 'DATA', STUDY => ['java.io.ByteArrayOutputStream'], ) ; my $os = new java::io::ByteArrayOutputStream() ; my $scalar = "test\n" ; print $scalar ; my @bytes = map {ord($_)} split(''

Re: Using java Strings from within perl

2005-09-22 Thread Jason Stelzer
Patrick LeBoutillier wrote: >Suppose you call a Java method (from Perl) that returns a String. What >does Inline::Java do with the String? It nicely converts it to a Perl >scalar for you and allows you to forget all about the String object. >Unfortunately that exactly what is happening here also :

Re: Using java Strings from within perl

2005-09-16 Thread Patrick LeBoutillier
Jason, Although the idea is good, what your trying to do can't work. And when you think about it it's actually really simple. Suppose you call a Java method (from Perl) that returns a String. What does Inline::Java do with the String? It nicely converts it to a Perl scalar for you and allows you

Using java Strings from within perl

2005-09-16 Thread Jason Stelzer
Hello, I've been using Inline::Java to do some integration work. Its been quite successful over all. However, I've come upon a simple task that I'm either going about completely the wrong way, or I've found a minor problem. The short version is I want to convert a perl string into a java byte[] ar