#! perl -slw use strict; use Data::Dumper; my @hash; while( my $line = ) { chomp $line; push @{ $hash[ $_ ] }, substr $line, $_, 2 for 0 .. length( $line ) -2; } print Dumper \@hash; __DATA__ ABCDEFGHIJKLM abcdefghijklm NOPQRSTUVWXYZ nopqrstuvwxyz #### #! perl -slw use strict; use Data::Dumper; my %hash; while( my $line = ) { chomp $line; push @{ $hash{ $_ } }, substr $line, $_, 2 for 0 .. length( $line ) -2; } print Dumper \%hash; __DATA__ ABCDEFGHIJKLM abcdefghijklm NOPQRSTUVWXYZ nopqrstuvwxyz