jeiku has asked for the wisdom of the Perl Monks concerning the following question:
but my code doesn't work:"value 1","something else","other stuff" "asdf123","omg","hope this works" "more tests","testy","blah"
I can't seem to get the regular expression in the split statement to work. This needs to match special characters, words and numbers inbetween#!/usr/bin/perl $file = "new.txt"; open(FILE, $file) or die "$!\n"; @data = <FILE>; close(FILE); foreach $entry (@data) { ($var1, $var2, $var3) = split(/\"\W\"\,/, $entry); print "Var1: $var1\n"; print "Var2: $var2\n"; print "Var3: $var3\n"; }
Please help, thanks!"",
2006-03-30 Retitled by planetscape, as per Monastery guidelines
Original title: 'Regex help'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with Regex in Split
by Corion (Patriarch) on Mar 29, 2006 at 08:01 UTC | |
|
Re: Help with Regex in Split
by GrandFather (Saint) on Mar 29, 2006 at 08:15 UTC | |
|
Re: Help with Regex in Split
by davorg (Chancellor) on Mar 29, 2006 at 08:06 UTC | |
|
Re: Help with Regex in Split
by davido (Cardinal) on Mar 29, 2006 at 08:10 UTC | |
|
Re: Help with Regex in Split
by jeiku (Acolyte) on Mar 29, 2006 at 08:22 UTC | |
|
Re: Help with Regex in Split
by johngg (Canon) on Mar 29, 2006 at 09:49 UTC |