deMize has asked for the wisdom of the Perl Monks concerning the following question:
RECORD 1 ###### Full Name 1a Street Address 1a City 1a ST1a Zip_1a + COUNTY 1a 0######## Full Name 1b abcABCabc 99/99/9999 Street Address 1b City 1b ST1b Zip_1b + COUNTY 1b RECORD 2 ############ Full Name 2a 99/99/9999 Street Address 2a City 2a ST2a Zip_2a + COUNTY 2a 0### Full Name 2b abcABCabc 99/99/9999 Street Address 2b City 2b ST2b Zip_2b + COUNTY 2b
Please understand that this is my best attempt of simplifying my code and the program is a little more intense than I'm able to show you. While I welcome best practices, keep in mind that they may already be in place --- and know I appreciate your help (as always).if ($array[$line] =~ /0?.*?(RECORD .*)/){ $record = trim($1); # works correctly $array[$line+1] =~ /(\d+)(.*)/; $id = trim($1); # works correctly $name = trim($2); # works correctly # still looking at the "a" lines, sometimes there's a date, sometim +es no date $array[$line+2] =~ /.*?(\d{2}\/\d{2}\/\d{4})?(.*)/; $date = trim($1); # when no date it's using the previous $1 that + goes into $id $address = trim($2); # when no date it's using the previous $2 that + goes into $name ... code continues ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing Regex
by GrandFather (Saint) on Sep 23, 2009 at 02:02 UTC | |
by deMize (Monk) on Sep 23, 2009 at 14:25 UTC | |
by GrandFather (Saint) on Sep 23, 2009 at 20:25 UTC | |
|
Re: Parsing Regex
by muba (Priest) on Sep 23, 2009 at 00:48 UTC | |
by deMize (Monk) on Sep 23, 2009 at 01:02 UTC | |
by muba (Priest) on Sep 23, 2009 at 01:12 UTC | |
by deMize (Monk) on Sep 23, 2009 at 13:48 UTC | |
by deMize (Monk) on Sep 23, 2009 at 14:56 UTC | |
by deMize (Monk) on Sep 23, 2009 at 05:34 UTC |