[EMAIL PROTECTED] wrote:
H'lo, g'morning Perl People - and Merry Christmas!
I've got a couple quickie questions that are messing me up. They
should be relatively easy, but I guess since I've been up since
YESTERDAY working on this, my brain isn't cooperating now. I'm no
master programmer, I'm just trying to modify a script I bought to be,
well, BETTER.
1) If my program gets a result in a string, and the string's value is:
Quincy, IL; Heath, OH; Bowling Green, KY; Muncie, IN; Paducah, KY;
Gastonia, NC
>
How do make it so that the strings value is only those cities in Kentucky?
(the string would now be set to just "Bowling Green, KY; Paducah, KY")
I would probably split on /\s*;\s*/ and then loop over the array looking
for elements with /KY$/, push them onto a new array and join them again
with ';'.
2) A string is being set, and the result is a date, and the date comes back
a couple of different ways:
12/23/2002 Dec 23 12/23
and I want it to always be like the first value, 12/23/2002. If it's in
the
format 12/23/2002, leave it alone. If it's not, and change it to where it
IS. How can this be done?
I guess I would brute force it with an if/elsif and use a RE for each possibility.
And the third, the worse one, it's parsing input received, and it's like
this:
while($content =~ m|<td valign=\"top\" class=\"list-item-odd\"><a
href=\"(.*?)\"
class=\"list-item-title\"><b>(.*?)</b></a><br>([\w\W]*?)<td
valign=\"top\" class=\"list-item-odd\">(.*?)<br>([\w\W]*?)<td
valign=\"top\" class=\"list-item-odd\">(.*?)</td>([\w\W]*?)<td
valign=\"top\" class=\"list-item-odd\">(.*?)</td>|igmo) {
You don't need to escape the "s above - that should make it a lot easier to read.
But the value, every EVEN time, which it's therefore missing (I'm assuming)
looks like this:
while($content =~ m|<td valign=\"top\" class=\"list-item\"><a
href=\"(.*?)\"
class=\"list-item-title\"><b>(.*?)</b></a><br>([\w\W]*?)<td
valign=\"top\" class=\"list-item\">(.*?)<br>([\w\W]*?)<td valign=\"top\"
class=\"list-item\">(.*?)</td>([\w\W]*?)<td valign=\"top\"
class=\"list-item\">(.*?)</td>|igmo) {
What could the line look like if it was only looking for list-item in
the line
with everything else, no matter if its a line with list-item-odd or not?
If I grab your meaning, you should be able to just change each occurrence
of '-odd' to '(-odd)?' unless you don't mean that literally - in which
case you may need '(list-item-odd|list-item)'
Thank you so very much! I've been working on these modifications and
working
on them, but I need sleep badly, so I'm giving up and flat out asking for
help in solving it. Thank you, I appreciate your time.
--
,-/- __ _ _ $Bill Luebkert ICQ=162126130
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs