my @array = ( "a", "b", "c" );
my $aref = [ "x", "y", "z" ];
push @array, $aref;
# Current value for @array:
#@array = (
# "a",
# "b",
# "c",
# [
# "x",
# "y",
# "z"
# ],
# )
####
#!/usr/bin/env perl
use strict;
use warnings;
my @array;
while () {
chomp;
my ($bool,$int) = split ",";
# Take each ($bool,$int) tuple, and store it in an array reference
# (By placing it in []) that we add to our array
push @array, [ $bool, $int ];
}
# Cycle through our array of array references and print them
foreach my $entry (@array) {
print "Bool: " . $entry->[0] . "\n"; # The -> dereferences our arrayref
print "Int: " . $entry->[1] . "\n\n"; # The -> dereferences our arrayref
}
__DATA__
0,14
0,7
1,13
0,3
1,9
0,2
1,1
####
perl-fu@nexus:~/foo$ ./a_of_a.pl
Bool: 0
Int: 14
Bool: 0
Int: 7
Bool: 1
Int: 13
Bool: 0
Int: 3
Bool: 1
Int: 9
Bool: 0
Int: 2
Bool: 1
Int: 1