$file_name =~ /^[A-Z]/i; push @{$arrays->{$1}}, $infoline; #### for $key (keys %$arrays){ for $element (@{$arrays->{$key}}){ print $element; } }