[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-win32-users
Subject:    RE: [Perl-unix-users] String Parse
From:       "Gerber, Christopher J" <Christopher.J.Gerber () pfizer ! com>
Date:       2002-12-24 14:33:17
[Download RAW message or body]

> -----Original Message-----
> From: skarr@bellsouth.net [mailto:skarr@bellsouth.net]
> H'lo, g'morning Perl People - and Merry Christmas!
> 
Merry Christmas to you too!  (And Happy Holidays to the rest of you...)

> 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.
> 
I'll see what I can do...

> 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")
> 
How about something like this:
$_ = 'Quincy, IL; Heath, OH; Bowling Green, KY; Muncie, IN; Paducah, KY;
Gastonia, NC';
map {push @_town, /([^,]+, KY)/} (split /; /);
$_ = join '; ', @_towns;
print;

> 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'm sure someone else will get this one for you... I don't usually play w/
dates and it's too early for me to do research!

> 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) {
> 
> 
> 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.
> 
I don't quite understand what you're doing... it's still pretty early. ;)
You might be able to do something like:
	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) {

By adding more another pair of parenthesis, I'm shifting the values of $1
and the like.

Hope this helps...


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be \
privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone \
else is unauthorized. If you are not an addressee, any disclosure or copying of the \
contents of this E-mail or any action taken (or not taken) in reliance on it is \
unauthorized and may be unlawful. If you are not an addressee, please inform the \
sender immediately. _______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic