Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Can some please explain the below BEGIN routine? what does 'or','u','v] mean?

BEGIN { CreateCmdLineVar('$Dut', ['or', ['u'], ['v']], ); CreatejeVar('$CM_etadId', ['v'], undef); CreatejeVar('$ACM_Id', ['v'], undef); }

Replies are listed 'Best First'.
Re: Help understand BEGIN routine
by tobyink (Canon) on Mar 11, 2012 at 21:09 UTC

    Is this simpler?

    BEGIN { my @array_containing_u = ("u"); my @array_containing_v = ("v"); my @array_starting_with_or = ("or"); push @array_starting_with_or, \@array_containing_u; push @array_starting_with_or, \@array_containing_v; CreateCmdLineVar('$Dut', \@array_starting_with_or); my @another_array_containing_v = ("v"); CreatejeVar('$CM_etadId', \@another_array_containing_v, undef); my @yet_another_array_containing_v = ("v"); CreatejeVar('$ACM_Id', \@yet_another_array_containing_v, undef); }

      Simpler but ..can someone please explain in words?sorry for my ignorance

        Simpler but ..can someone please explain in words?sorry for my ignorance

        Sure, but that is unlikely to remedy your situation

Re: Help understand BEGIN routine
by aaron_baugher (Curate) on Mar 12, 2012 at 01:16 UTC
    CreateCmdLineVar('$Dut',     ['or', ['u'], ['v']], );

    This calls the named subroutine with two values: the string $Dut (which is not interpolated, because of the single quotes), and an array reference. The array reference points to an array with three values:

    1. the string 'or'
    2. an array reference pointing to an array containing one element, the string 'u'
    3. an array reference pointing to an array containing one element, the string 'v'

    When you understand that, you can figure out what the other two lines are doing.

    Aaron B.
    My Woefully Neglected Blog, where I occasionally mention Perl.

Re: Help understand BEGIN routine
by rovf (Priest) on Mar 12, 2012 at 09:33 UTC
    what does 'or','u','v' mean
    'u' is a string literal containing only one letter (u). ['u'] is a reference to an array containing only one element (which happens to be the aforementioned string).

    -- 
    Ronald Fischer <ynnor@mm.st>