in reply to Nth match.
(which can handle escaped (backslashed) contents, too, change tomy $term = qr/"[^"\\]*(?>\\.[^"\\]*)*"|[^,"]*/;
if you escape quotes by doubling them)my $term = qr/"[^"]*(?>""[^"]*)*"|[^,"]*/;
And then you can do
which seems to work well for me... BTW it's "while", not "While"./^$term,$term,$term,($term)/o;
Result:my $term = qr/"[^"\\]*(?>\\.[^"\\]*)*"|[^,"]*/; while (<DATA>) { /^$term,$term,$term,($term)/o and print "$1\n"; } __DATA__ 6,0,3,"8.1",1 7,578,,"8.2,r1",1 8,0,5,"8.2,r3",1 18,0,13,"6.2",1 19,D610,,"6.3,r1",1 20,2f78,15,"6.3,r2",1
"8.1" "8.2,r1" "8.2,r3" "6.2" "6.3,r1" "6.3,r2"
|
|---|