in reply to Re: Matching part of a line and saving it into a variable
in thread Matching part of a line and saving it into a variable
#!/usr/local/bin/perl open (MYFILE, 'shoplist.csv'); while (<MYFILE>) { chomp; if (/\"(.*)\"/) { my ($first,$last) = split('\s', $_); + print "$last $first\n"; } } close (MYFILE);
It's working decently, how do you get rid of commas and a double quote in a line? For example, the names are coming out like:
Last, "First
I'd like to remove the comma and the double quote so I can just have the last and first name. I'm getting pretty close, all that's left is to figure out how to save the middle initial!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Matching part of a line and saving it into a variable
by GrandFather (Saint) on Mar 14, 2011 at 09:46 UTC |