in reply to Perl is returning... odd results... from regular expressions. Things matching when they shouldn't, and stuff like that.

split /(\".*?\"(?=,))|(.*?(?=,))|(.*?(?=\n))/
Yeeech. I guess when all you have in your toolbox is a hammer, everything gets a little banged up, regardless.

Had you considered using @result = /pattern/g instead of split? What I've found is that in general, if it's easier to talk about what you're keeping than what you're throwing away, the match wins over the split.

  • Comment on Re: Perl is returning... odd results... from regular expressions. Things matching when they shouldn't, and stuff like that.
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Perl is returning... odd results... from regular expressions. Things matching when they shouldn't, and stuff like that.
by Groxx (Novice) on Jan 11, 2007 at 08:07 UTC
    I'll definitely give that a try. I tend to bite off more than I can chew at times, and this is my first real Perl project, so I wasn't quite sure what to do.

    Thanks! This should help clean up some of the results, to say the least :)