my @fields = qw(name num1 num2); open(IN, "<$mailer_data_location"); while () { chomp; my %data; my @data{@foo} = split /\|/, $_; print $_ if $data{name} eq 'Bill'; # Save array of hashes push @AoH, \%data; # Or just save array of values push @array, [ split /\|/, $_ ]; } close(IN);