PerlCtrl and arrays of arrays

Discussion in 'Perl Misc' started by axtens, Feb 20, 2008.

  1. axtens

    axtens Guest

    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.
    axtens, Feb 20, 2008
    #1
    1. Advertising

  2. axtens

    Dr.Ruud Guest

    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."
    Dr.Ruud, Feb 20, 2008
    #2
    1. Advertising

  3. 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
    Martijn Lievaart, Feb 20, 2008
    #3
  4. axtens

    axtens Guest

    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.
    axtens, Feb 21, 2008
    #4
  5. axtens

    axtens Guest

    axtens, Feb 21, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paolo Asioli

    PerlCtrl and sending back events

    Paolo Asioli, Dec 30, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    74
    Paolo Asioli
    Dec 30, 2003
  2. Dol
    Replies:
    0
    Views:
    82
  3. AJ

    PerlCtrl and C++

    AJ, Dec 22, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    121
  4. axtens

    PerlCtrl, COM objects and callbacks

    axtens, Feb 7, 2008, in forum: Perl Misc
    Replies:
    1
    Views:
    105
    Ben Morrow
    Feb 7, 2008
  5. axtens

    PerlCtrl's IDL and enums

    axtens, Feb 9, 2008, in forum: Perl Misc
    Replies:
    2
    Views:
    95
    axtens
    Feb 11, 2008
Loading...

Share This Page