use Path::Tiny; my $file = 'index.txt'; my %zipcodes = map { $_, 1 } path( $file )->lines({chomp => 1});