my @tags = qw( ID Name Major Email ); #open FILE, '/home/ajb004/Paradigms/roster.txt' or die $!; while ( ) { chomp; ## needed to get rid of \n on e-mail address s/_/ /g; # this doesn't need to be in the inner loop my %fields; my @fields{ @tags } = split /,/; #this is actually a regex print "\n"; foreach my $tag ( @tags ) { print " $tag: $fields{$tag}\n"; } print "\n"; }