[EMAIL PROTECTED] wrote:
H'lo, g'morning Perl People - and Merry Christmas!

Gmrn....

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'd split on /;/ then split on ',' and keep it if the last element eq KY.

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 think you might use Date::Manip, simply:
"
use Date::Manip;

&Date_Init("TZ=EST");
my @dates = ('12/23/2002', 'Dec 23', '12/23');

foreach my $date (@dates){        my $newdate = ParseDate($date);
#$year = 2002 unless defined $year;
print  "$newdate\n";}
"
(The module is at the AS repository for ppm)

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) {


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) {

Here, I'd consider splitting the strings based on the formatting, which seems consistent (having the actual data sample would help, perhaps for testing it for you). It appears you're perhaps capturing the .*? strings?

Anyway, you could do that, or use (since it seems to be html) something to parse that and extract the text from the tags..?? Like HTML::TokeParser ??


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?

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.

Merry Christmas,

Steve
To you too.

HTH

--
Michael Higgins

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to