Click here to get back home

PerlCtrl and arrays of arrays

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
PerlCtrl and arrays of arrays axtens 02-20-2008
Get Chitika Premium
Posted by axtens on February 20, 2008, 1:44 am
Please log in for more thread options
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.

Posted by Dr.Ruud on February 20, 2008, 2:32 am
Please log in for more thread options
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 ],
);

--
Affijn, Ruud

"Gewoon is een tijger."

Posted by Martijn Lievaart on February 20, 2008, 3:15 am
Please log in for more thread options
On Wed, 20 Feb 2008 08:32:31 +0100, Dr.Ruud wrote:

> 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

Posted by axtens on February 20, 2008, 10:29 pm
Please log in for more thread options
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.

Similar ThreadsPosted
Difference between accessing arrays and associative arrays using a int index April 12, 2006, 12:58 am
comparing 2 arrays strings when the number/name of arrays is dynamic October 22, 2006, 3:19 am
arrays of arrays question October 24, 2004, 3:49 am
FAQ: How do I compute the difference of two arrays? How do I compute the intersection of two arrays? October 11, 2004, 11:10 am
FAQ 4.43: How do I compute the difference of two arrays? How do I compute the intersection of two arrays? October 24, 2004, 5:03 pm
FAQ 4.43: How do I compute the difference of two arrays? How do I compute the intersection of two arrays? November 21, 2004, 12:03 pm
FAQ 4.43: How do I compute the difference of two arrays? How do I compute the intersection of two arrays? December 30, 2004, 6:03 pm
FAQ 4.43: How do I compute the difference of two arrays? How do I compute the intersection of two arrays? January 6, 2005, 12:03 pm
FAQ 4.43 How do I compute the difference of two arrays? How do I compute the intersection of two arrays? January 18, 2005, 12:03 pm
FAQ 4.43 How do I compute the difference of two arrays? How do I compute the intersection of two arrays? May 1, 2005, 11:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap