sub read_db_list { my %listdb; # ... in the read loop # replacing the if block push @{$listdb{ uc substr( $file_name, 0, 1) }}, $infoline; # after all is read return \%listdb; }