Hello friends,
I recently ran into a problem with my perl prog that reads from a flat text file for patterns and was hoping that one of the many Perl guru here can give me a hand or drop a few lines of suggestions.
My problem is as follow: My prog use to read one line of text at a time from a flat file. It splits the "Before text:" below whenever there are two spaces or more are found(example: $time=10:00 AM, $event=Morning Meeting, $room=Room 100). However, the creator of the file (which I can not control) sometimes play tricks on me and only puts in one space between the "10:00 AM" and the "Morning Meeting". This result in my variables having the wrong data (example: $time=10:00 AM Morning Meeting, $event=Room 100, $room=).
Please show me how to resolve this problem or just any general suggestion how you would do the "split" differently. My line of code is just a simple:
($k, $l, $m) = split(/\ +/,$text);
Thank you in advance.
Before text:
10:00 AM Morning Meeting Room 100
Results:
$time=10:00 AM, $event=Morning Meeting, $room=Room 100
-------------
Problem Text:
10:00 AM Morning Meeting Room 100
Bad Results:
$time=10:00 AM Morning Meeting, $event=Room 100, $room=
I recently ran into a problem with my perl prog that reads from a flat text file for patterns and was hoping that one of the many Perl guru here can give me a hand or drop a few lines of suggestions.
My problem is as follow: My prog use to read one line of text at a time from a flat file. It splits the "Before text:" below whenever there are two spaces or more are found(example: $time=10:00 AM, $event=Morning Meeting, $room=Room 100). However, the creator of the file (which I can not control) sometimes play tricks on me and only puts in one space between the "10:00 AM" and the "Morning Meeting". This result in my variables having the wrong data (example: $time=10:00 AM Morning Meeting, $event=Room 100, $room=).
Please show me how to resolve this problem or just any general suggestion how you would do the "split" differently. My line of code is just a simple:
($k, $l, $m) = split(/\ +/,$text);
Thank you in advance.
Before text:
10:00 AM Morning Meeting Room 100
Results:
$time=10:00 AM, $event=Morning Meeting, $room=Room 100
-------------
Problem Text:
10:00 AM Morning Meeting Room 100
Bad Results:
$time=10:00 AM Morning Meeting, $event=Room 100, $room=