I tried to post before and for some reason it didn't work.
I dunno why not.

Anyway this is a different approach. Have fun!

#!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

In reply to Re: How do I combine SPLIT with trimming white space by Marshall
in thread How do I combine SPLIT with trimming white space by Grey Fox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.