Question: I'm trying to make an array of hashes. This is my code. The $1, $2, etc are matched from a regular expression and I've checked they exist.

**Update:** Fixed my initial issue, but now I'm having the problem that my array is not growing beyond a size of 1 when I push items onto it...

**Update 2:** It is a scope issue, as the @ACLs needs to be declared outside the loop. Thanks everyone!

```
while (<>) {
    chomp;
    my @ACLs = ();

    #Accept ACLs
    if($_ =~ /access-list\s+\d+\s+(deny|permit)\s+(ip|udp|tcp|icmp)\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\s+eq (\d+))?/i){

        my %rule = (
            action => $1, 
            protocol => $2, 
            srcip => $3, 
            srcmask => $4, 
            destip => $5, 
            destmask => $6, 
        );
        if($8){
            $rule{"port"} = $8;
        }
        push @ACLs, \%rule;
        print "Got an ACL rule.  Current number of rules:" . @ACLs . "\n";

```

The array of hashes doesn't seem to be getting any bigger.

Answer: 
You are pushing `$rule`, which does not exist. You meant to push a reference to `%rule`:

```
push @ACLs, \%rule;

```

Always start your programs with `use strict; use warnings;`. That would have stopped you from trying to push `$rule`.

**Update:** In Perl, an array can only contain scalars. The way complex data structures are constructed is by having an array of hash references. Example:

```
my %hash0 = ( key0 => 1, key1 => 2 );
my %hash1 = ( key0 => 3, key1 => 4 );
my @array_of_hashes = ( \%hash0, \%hash1 );
# or: = ( { key0 => 1, key1 => 2 }, { key0 => 3, key1 => 4 ] );

print $array_of_hashes[0]{key1}; # prints 2
print $array_of_hashes[1]{key0}; # prints 3

```

Please read the [Perl Data Structures Cookbook](http://perldoc.perl.org/perldsc.html).
You’re clearing `@ACLs` each time through the loop. Your `my` is misplaced.