
adam_wood1234
New User
Sep 20, 2004, 1:32 AM
Post #1 of 2
(374 views)
|
|
Data from a file cont.....
|
Can't Post
|
|
Alright chaps, thanks for answering my last query, I now have another one which I hope you can help with. I am trying to come to terms with RE's for processing strings. I have a file with address data that needs to be parsed by my program, the data in the file comes in the following formats *~ROAD/SUBURB,TOWN,COUNTY *SUB-ROAD,ROAD/SUBURB,TOWN,COUNTY *SUB-ROAD~ROAD/SUBURB,TOWN,COUNTY My program needs to read each line and determine if there is a sub-road present, if there is the data in the sub-road field is put into a variable with any data after that put into an address variable. So far my statement looks like: if ($line =~ /~/) { $line =~ /^\*([^~]*)~([^\*].*)/; $subRoad = $1; $address = $2; } else { $line =~ /^\*([^\*].*)/; $subRoad = ""; $address = $1; }This manages to parse the first two format types, the third format (*SUB-ROAD~/ANY OTHER DATA) I am struggling on finding the correct statement for. Any help would be greatly appreciated.
|