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

Using what you said as a template, I've come up with this so far:
#!/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

    My template used strictures (use strict; use warnings;), didn't require an external file, and provided some sample data. You didn't use my template!

    Unless you show us a few lines of sample data, the output you expect and the output you see there is not much we can do to help. We are at least as lazy as you are so if you want our help you are going to have to work hard to make it easy for us. After all, I worked hard to provide you a template in the hope that I wouldn't have to write all this lot. Looks like I failed!

    True laziness is hard work