#!usr/bin/perl -w use strict; # I suspect that you left off a ";" after Boop, Elizabeth PHD # I add added that to the test data below. my $file_data =qq( Builder, Bob ;Stein, Franklin MSW; Boop, Elizabeth PHD ; Cc: Bear, Izzy; SomeGuy, Guy; Einstein , Albert PHD; ); # #yes, you can open a scalar for read with a filehandle! #there is some "weirdness" about this, but the idea does work! open (my $in, "<", \$file_data) or die "can't open input file $!"; while (my $line =<$in>) { next if $line =~ m/^\s*$/; # skip blank lines chomp ($line); $line =~ s/CC://i; $line =~ s/\s+$//; #gets rid of trailing \n #I suspect that this is an artifact #of the way the file is opened?? my @whole_name_titles = split(/;/,$line); foreach my $name (@whole_name_titles) { $name =~ s/\s+[A-Z]+\s*$//; #Skip trailing cap letters $name =~ s/\s+//g; #compress spaces print "$name\n"; #push to DB or whatever here... } } __END__ Prints: Builder,Bob Stein,Franklin Boop,Elizabeth Bear,Izzy SomeGuy,Guy Einstein,Albert