What do you think of this?
use Modern::Perl;
while (<DATA>) {
my ($last, $first, $mid) = /^,"([^",]+),\s([^\s"]+)\s?([^"]*)/;
say "LAST: $last FIRST: $first MID: $mid" if $last;
}
__DATA__
"Barber Shop: NW, 147-2220, Washington 992,,,,,
,"Lawrence, Jerry A.",Buzz,,Clean,Cash,,
,"Wallace, Bob W.",Caesar,,High,Credit,,
,"Anthony, Ronald",Caesar,,Close,Cash,,
,"Nelson, Dwight R.",Buzz,,Clean,Check,,
,"Jamison, Jeff S.",Caesar,,High,Credit,,
,"Favors, Eric S.",Shave,,Skin,Cash,,
,"Williams, Herb C.",Fade,,High,Check,,
,"Carter, Shaun ",Caesar,,Low,Cash,,
Output: LAST: Lawrence FIRST: Jerry MID: A.
LAST: Wallace FIRST: Bob MID: W.
LAST: Anthony FIRST: Ronald MID:
LAST: Nelson FIRST: Dwight MID: R.
LAST: Jamison FIRST: Jeff MID: S.
LAST: Favors FIRST: Eric MID: S.
LAST: Williams FIRST: Herb MID: C.
LAST: Carter FIRST: Shaun MID:
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|