I have modified your code and added comments (with **) to let you know what's changed and what you might have misunderstood. Hope this helps.
use strict; use warnings; # a plethora of my's ...strict baffles me # ** deleted ** Wait until you need them to declare them #two arrays of arrays to populate # ** Starting out as arrays of strings my @aoa=qw/header font content/ ; my @aoac=qw/headerc fontc contentc/; # array of array values my @contents=( ["html","head","body",], ["font","face","size","color"], ["h1","p","code"] ); #scalar ref to array for later population my $scalarclose=\@aoac; #** Now @$scalarclose is the same as @aoac #** and $scalarclose->[1] is the same as $aoac[1], etc. #populate the aoa # ** you're just copying. Same as @aoa = @contents; #** Declare this outside the loop, so it doesn't get reset every itera +tion my $i; #use contents of populated aoa foreach my $val (@aoa) { # an incrementer hacked to use for populating # an aoa with modified values ++$i; my $count=$i-1; #get values from original aoa and modifiy, #begin population of new aoa our $length=scalar @$val; my @ctags; for (0...$length-1) { my $ctag="<\\$val->[$_]>"; push @ctags, $ctag ; } my $newlength=$length+1; #** You never do anything with this, but... my @ctagarray=splice @ctags, 0, $newlength; #this line is problematic #** What do you want to do with scalarclose? It is a scalar (array + ref) $scalarclose->[$count]=[map {$_} @ctagarray]; #** or @$scalarclose = map {$_} @ctagarray; #** of course, your map is just identity, so that's @$scalarclose = @ctagarray; } #scalar refs to aoa #** values are being copied from @aoac, which was never an AoA. my $headc=$aoac[0]; my $fontc=$aoac[1] ; my $contentc=$aoac[2]; #** So let's copy from @aoa, which is an AoA ($headc, $fontc, $contentc) = @aoa; #print to see the populus >>broken<< #** Since we copied references into them, you can now dereference them print " $headc->[1]\n"; print " $fontc->[1]\n"; print " $contentc->[1]\n";

Caution: Contents may have been coded under pressure.

In reply to Re: Populating Arrays of Arrays by Roy Johnson
in thread Populating Arrays of Arrays by dReKurCe

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.