Well, you can do what Chris suggested, but it does not handle leading and trailing spaces in $ file_data.
You can add processing for these files as follows:
$file_data =~ s/\A\s+|\s+\z//g;
Also note that using a second array is not required. Check this:
my $file_data = 'Builder, Bob ;Stein, Franklin MSW; Boop, Elizabeth PHD Cc: Bear, Izzy'; my @email_list; $file_data =~ s/CC:/;/ig; $file_data =~ s/PHD//ig; $file_data =~ s/MSW//ig; my @tmp_data = split( /;/, $file_data ); foreach my $entry (@tmp_data) { $entry =~ s/^[ \t]+|[ \t]+$//g; } foreach my $name ( sort(@tmp_data) ) { print "$name \n"; }
user80168
source share