#!/usr/bin/perl use strict; use warnings; my @tag_template = ('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 my @word = split(/,/); #this is actually a regex my @tags = @tag_template; #copy is not a big deal here print "\n"; foreach my $word (@word) { $word =~ s/_/ /g; my $tag = shift(@tags); print " $tag: $word\n"; } print "\n"; } =Prints: ID: 123456 Name: Susie Smith Major: Computer Science Email: ssmith@usomewhere.edu ID: 234567 Name: John Smith Major: Computer Engineering Email: jsmith@usomewhere.edu =cut __DATA__ 123456,Susie_Smith,Computer_Science,ssmith@usomewhere.edu 234567,John_Smith,Computer_Engineering,jsmith@usomewhere.edu