Good Evening Perl Monks, How can one assign the contents of an array within a multi-dimensional array to a set of variables passed to a subroutine?

use warnings; use Data::Dumper; my @arr; $arr[0][4] = (["S","M","R","B"]); print Dumper @arr; my ($VAR1,$VAR2,$VAR3,$VAR4) = @{$arr[0][4]}; print "Var1: $VAR1\tVar2: $VAR2\tVar3: $VAR3\tVar4: $VAR4\n"; Testing($arr[0][4]); sub Testing () { my ($VAR5,$VAR6,$VAR7,$VAR8) = @{$_}; print "Var5: $VAR5\tVar6:$VAR6\tVar7: $VAR7\tVar8: $VAR8\n"; }
OUTPUT ================= main::Testing() called too early to check prototype at C:\temp\arr_ref +ernce.pl line 11. $VAR1 = [ undef, undef, undef, undef, [ 'S', 'M', 'R', 'B' ] ]; Var1: S Var2: M Var3: R Var4: B Use of uninitialized value $_ in array dereference at C:\temp\arr_refe +rnce.pl line 14. Use of uninitialized value $VAR5 in concatenation (.) or string at C:\ +temp\arr_refernce.pl line 15. Use of uninitialized value $VAR6 in concatenation (.) or string at C:\ +temp\arr_refernce.pl line 15. Use of uninitialized value $VAR7 in concatenation (.) or string at C:\ +temp\arr_refernce.pl line 15. Use of uninitialized value $VAR8 in concatenation (.) or string at C:\ +temp\arr_refernce.pl line 15. Var5: Var6: Var7: Var8:
Expecting output ============== Var1: S Var2: M Var3: R Var4: B Var5: S Var6: M Var7: R Var8: B

In reply to Assign valuse of array within array to variables by g_speran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.