Hey fellow perl monks,
I'm still wrapping my head around how to correctly dereference. (I read the similar posts prior to posting, but unfortunately am still a bit cloudy on the concept.)
I have the following array, which internally is composed of two arrays. (BTW, I am using strict and warning pragmas.)
use strict; use warnings;
my @a1; my @a2;
where:
@a1 = ( "1MB", "2MB", ... )
and..
@a2 = ( "/home", "/home/debug", ... )
Both @a1 & @a2 are arrays which contain 51 rows. So, I populate these into my 2nd array.
my @b;
push (@b, [ @a1, @a2 ]);
However, when I try to print the results of @b:
sub newl { print "\n"; print "\n"; }
my $an1; my @an1;
$an1 = $#a1;
@an1 = ( 0, 1..$an1 );
for my $i (@an1) { print @b[$i]; &newl; }
I see references to the arrays:
ARRAY(0x81c0a10)
.
ARRAY(0x81c0a50)
.
.
.
How do I properly print this array? I know I need to dereference the array, I'm not sure how to go about doing this. I tried populating my array as such:
push (@b, [ \@a1, \@a2 ]);
Which produces the same results. I also tried:
for my $i (@an1) { print @{$b[$i]}; &newl; }
Which unfortunately errors due to having 0 as an array reference?
Can't use string ("0") as an ARRAY ref while "strict refs" in use at p_disk_ex6.pl line 42.
Any suggestions are greatly appreciated!
for my $i (@b) { print @{$i}; &newl; }without any luck. I receive the same error "Can't use string "0" as an array ref while using "strict refs." I'm not sure why I am seeing this error, why is 0 being interpreted as a string?