open(INFILE,$infile) or die "Can't open $infile\n"; print "opened $infile\n";; while(){ if(/(\s+)(\d+)(\.)(\s+)([A-Z]{2})(\s+)([A-Z]{5})/){ # this matches certain lines in my data files $number++; print "$2=>$5\n"; # this works and prints my key and value that I want $hash_codes{$2}=>$5;#useless } }