in reply to Help with Regex in Split
It's difficult to help when you don't tell us what the problem is. We only know that the code you've given us doesn't do what you want it to to - but you haven't told us what results you were expecting.
But my telepathy is strong this early in the morning and I think I've worked out what you want. You want to extract the three string values from each line of the data. You're looking for a lightweight CSV parser. Is that right?
If that's the case, then split might not be the best approach. I'd recommend using Text::ParseWords instead - it's a standard part of the Perl distribution.
#!/usr/bin/perl use strict; use warnings; use Text::ParseWords; my @data = <DATA>; foreach my $entry (@data) { my ($var1, $var2, $var3) = parse_line(',', 0, $entry); print "Var1: $var1\n"; print "Var2: $var2\n"; print "Var3: $var3\n"; } __DATA__ "value 1","something else","other stuff" "asdf123","omg","hope this works" "more tests","testy","blah"
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|