in reply to Re^2: Matching part of a line and saving it into a variable
in thread Matching part of a line and saving it into a variable
Lawrence, Jerry A. Wallace, Bob W. Anthony, Ronald Nelson, Dwight R. Jamison, Jeff S. Favors, Eric S. Williams, Herb C. Carter, Shaun
#!/db/bin/perl -w use strict; use warnings; my $filename = $ARGV[0]; open FILE, $filename or die $!; my $i = 0; while(<FILE>) { if($i == 0) { $i++; next; } chomp; if (/\"(.*?), (.*?)[" ]((.*?)\")?/) { my $last = $1; my $first = $2; my $mi = $4; if(defined $mi) { print "$last, $first $mi\n"; } else { print "$last, $first\n"; } } } close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Matching part of a line and saving it into a variable
by mistamutt (Novice) on Mar 14, 2011 at 20:35 UTC | |
by fidesachates (Monk) on Mar 14, 2011 at 20:48 UTC | |
|
Re^4: Matching part of a line and saving it into a variable
by CountZero (Bishop) on Mar 14, 2011 at 22:01 UTC | |
by fidesachates (Monk) on Mar 14, 2011 at 22:25 UTC |