This is a foray into 3 dimensional data structures.
The aoa in question is at the end, I can't seem to
sort out my references and dereferences.Guidence
is order,I'm not sure where this leads or how I am
thinking incorrectly.
I also have a bit of confusion surounding strictures:
Why does a scalar defreference of an array force
declarations to be made on the scalar and the array
with the scalar name?Seems redundant,but strict seems
important in the future of my studies.
Thanks
#! /usr/bin/perl use strict; use warnings; #a plethora of my's ...strict baffles me my @contents; my @aoa; my @ctags; my @ctagarray; my @aoac; my @headc; my @contentc; my @fontc; my @scalarclose; my $ctag; my $font; my $head; my $content; my $val; my $newlength; my $count; my $scalarclose; my $headc; my $fontc; my $contentc; my $i; #two arrays of arrays to populate @aoa=qw/header font content/ ; @aoac=qw/headerc fontc contentc/; # array of array values @contents=( ["html","head","body",], ["font","face","size","color"], ["h1","p","code"] ); #scalar ref to array for later population $scalarclose=\@aoac; #populate the aoa for (0...$#aoa){ $aoa[$_]=$contents[$_]; } #use contents of populated aoa foreach $val(@aoa){ # an incrementer hacked to use for populating # an aoa with modified values ++$i; $count=$i-1; #get values from original aoa and modifiy, #begin population of new aoa our $length=scalar @$val; for (0...$length-1){ $ctag="<\\$val->[$_]>"; push @ctags ,$ctag ; } $newlength=$length+1; @ctagarray=splice @ctags,0,$newlength; #this line is problematic @$scalarclose[$count]=map {$_}, @ctagarray; } #scalar refs to aoa $headc=$aoac[0]; $fontc=$aoac[1] ; $contentc=$aoac[2]; #print to see the populus >>broken<< print " $headc->[1]\n"; print " $fontc->[1]\n"; print " $contentc->[1]\n";
In reply to Populating Arrays of Arrays by dReKurCe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |