[ic] split or \$myvar is not parsing or interpolte in a right way

Peter peter at pajamian.dhs.org
Fri Dec 5 23:20:10 UTC 2008


On 12/05/2008 11:42 AM, jojospace wrote:
> Hi @all,
> 
> I try to use the split function in a perl tag. The split function is not
> working right. The same as an (global) usertag. But for this case, I've
> a workaround. But I found an other case of trouble, how to use a normal
> perl codes as an usertag.
> 
> A code like
> 
>  my $recipient = SOAP::Data->name("Recipient", \$mydata);
> 
> is not working properly. A "\" in front of "$mydata" make me mad.
> The resulting output of the SOAP is therefore broken.
> 
> I've no clue, why this both happens! Am I missing something information
> for both cases?
> 
> I use
> 
> OS: FreeBSD Version 8.0
> Perl: Version 5.8.8
> IC: Version 5.6.0
> 
> Any tips, tricks and helps, would be appreciated!
> 
> With finest Regards,
> 
> Joachim
> 
> 
> Sample codes:
> ----------------------------
> <html>
> <body>
> 
> TEST<br>
> [seti splittest]1111\n2222\n3333\n[/seti]
> Input: [scratch splittest]<br>
> <br>
> <br>
> The result is fine!!!
> <br>
> [perl]
>  my @list = "";
>  my $result = "";
>  @list = split("\n", "1111\n2222\n3333\n");
>  foreach (@list) {
>    $result =  $result. "list1 = " . $_ . "<br>";
>  }
> return $result;
> [/perl]
> 
> <br>
> Bug or features???
> <br>
> [perl]
>  my @list = "";
>  my $result = "";
>  my $result =  "Where is the result?<br>" . $Scratch->{splittest} . "<br>";
>  @list = split("\n", $Scratch->{splittest});
>  foreach (@list) {
>    $result =  $result. "list2 = " . $_ . "<br>";
>  }
> return $result;
> [/perl]
> <br>
> <br>
> 
> </body>
> </html>
> ----------------------------
> 
> Output:
> ----------------------------
> TEST
> Input: 1111\n2222\n3333\n
> 
> 
> The result is fine!!!
> list1 = 1111
> list1 = 2222
> list1 = 3333
> 
> Bug or features???
> Where is the result?
> 1111\n2222\n3333\n
> list2 = 1111\n2222\n3333\n
> ----------------------------

I don't see any \$mydata in the code above, but I can tell you why the
second split isn't working, it's not the split, it's because when you
use the [seti] tag to insert the string 1111\n2222\n3333\n into your
scratch variable it inserts the literal characters '\' and 'n' and not
the linefeed character "\n".  Your perl code then goes on to split on
the linefeed character (of which there is none because your input only
has literal '\' and 'n' characters).  This is not a bug, seti does not
do perl interpolation on input (in spite of the "i" in the tag name) it
only interpolates for ITL.



Peter



More information about the interchange-users mailing list