PerlCtrl and arrays of arrays

A

axtens

G'day everyone

How would I return an array of arrays from perl, eg
my @r = [1, 2, [3,4]];
such that VB/VBScript would think the data to be
r = array(1,2,array(3,4))

This is PerlCtrl specific I know, and yes I should take it to the
ActiveState list, but I thought I'd ask here anyway, just in case.

Kind regards,
Bruce.
 
D

Dr.Ruud

axtens schreef:
How would I return an array of arrays from perl, eg
my @r = [1, 2, [3,4]];
such that VB/VBScript would think the data to be
r = array(1,2,array(3,4))

This is PerlCtrl specific I know, and yes I should take it to the
ActiveState list, but I thought I'd ask here anyway, just in case.

Maybe you are looking for

my @r = (
1,
2,
[ 3, 4 ],
);

or for

my @r = (
[ 1 ],
[ 2 ],
[ 3, 4 ],
);
 
M

Martijn Lievaart

axtens schreef:
How would I return an array of arrays from perl, eg
my @r = [1, 2, [3,4]];
such that VB/VBScript would think the data to be
r = array(1,2,array(3,4))

This is PerlCtrl specific I know, and yes I should take it to the
ActiveState list, but I thought I'd ask here anyway, just in case.

Maybe you are looking for

my @r = (
1,
2,
[ 3, 4 ],
);

or my $r = [1, 2, [3, 4]];

M4
 
A

axtens

Okay, I think I've found a solution:

I found convertArrayToVBArray at http://www.perlmonks.org/?node_id=516137
and applied it to as below

sub test {
my $res = 1;
my $dat = "hello";
my @b = ("my", "dog", "has", 3, "fleas");
my $c = convertArrayToVBArray( \@b );
my @r = ( $res, $dat, $c);
my $a = convertArrayToVBArray( \@r );
return $a;
}

By using convertArrayToVBArray on the inner array, adding the result
to the outer array, and then pushing that array through
convertArrayToVBArray, I can hand back a VT_ARRAY|VT_VARIANT that is
equivalent to

Array( 1, "hello", Array( "my", "dog", "has", 3, "fleas" ))

I really ought to blog this.

Kind regards,
Bruce.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top