Question: I am parsing a file, and every odd line gives me a "letter" (A, B, C, etc), and every even line gives me a "binary sequence" (0101, 1111, 0001, etc).

I would like to create a hash of arrays (but if you think another datatype is more suitable, please let me know) to keep all lines organized.

I know the has of arrays could look like:

```
%HoA = (
    A  => [ "0001", "1010" ],
    B  => [ "0011", "1111", "0111" ],
    C  => [ "0000"],
);

```

and I know how to *access* information from this data type.

However, I am having trouble *creating* this data type.

For instance, I am able to correctly obtain the "letter" ($letter) and "binary sequence" ($seq) for the file, using something like:

```
while (<INPUT>) {
    s/[\n\r]//mg;

    if ( /^>/) {
        $letter = substr($_, 7, 1);
    }
    if ( /^[01]/) {
        $seq = $_;
    }
}

```

But I am unsure how to:

1. create the hash of arrays,
2. check first whether or not that "letter" exists already as a key in the hash
3. if the "letter" does not exist as a key, then how to create it as a new key
4. after either determining the "letter" already exists or creating it if it does not, how to add the "seq" as a value to the "letter".

If such a datatype cannot be created in Perl, then I would appreciate any advice on what sort of data type to turn to! I need to keep each "letter" attached to all its "sequences". 

Any help would be much appreciated!

Answer: 
To create the hash, just put `my %HoA;` at the beginning of your code. Given a `$letter` and `$seq`, you can accomplish steps 2-4 at once by just doing `push @{$HoA{$letter}}, $seq;`, and Perl takes care of the details.
Check [perl data structures cookbook](http://perldoc.perl.org/perldsc.html#HASHES-OF-ARRAYS).

```
my %HoA;
my $letter;
while (<INPUT>) {
    s/[\n\r]//g;

    if ( /^>/) {
        $letter = substr($_, 7, 1);
    }
    if ( /^[01]/) {
        #  $seq = $_;
        push @{ $HoA{$letter} }, $_;
    }
}

```