my @colNames = qw(name status class major po phone advisor email); while (<>) { chomp; my %hash; @hash(@colNames) = /^(\w+, \w+ (?:\w+)?)\s*(\w+)\s* .../; print "$hash{name}\n"; print OUTPUT "$hash{name}\n"; } close OUTPUT || die "Cannot close OUTPUT: $!\n";