in reply to Re: my code error-ing out trying to grab html
in thread my code error-ing out trying to grab html

Hi,
You were correct - the regex isn't matching. Here's a fixed-up and /x modified version:
#!/usr/bin/perl -w use strict; my $row = "Updated: Mar-11 23:05:50 PST"; if($row =~ /Updated\s*: #The String "Updated", followed b +y zero or more spaces, then a colon \s*\w+\s*-\s*\d{1,2}\s* #This matches " Mar-11 " \d{1,2}:\d{1,2}:\d{1,2} #The time \s*PST/x) { #The timezone - do you really nee +d to be this specific? print "Match\n"; } else { print "No Match\n"; }
On the other hand: should you really be using a regex for this at all?
If it's a date, then Date::Calc could do very well for you (check out parse_date).
I'd also recommend thinking about whether you really need to have " PST" in your regex at all - do all the "Updated" strings contain that timezone information?
hope this helps
davis
Is this going out live?
No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist
Update: On re-reading your code, it appears that you're using parentheses to try and capture the whole string - these need to go inside the regex delimeters.
And I won't even mention that you should be "use"ing "strict" and "warnings" ;-)

Replies are listed 'Best First'.
Re: Re: Re: my code error-ing out trying to grab html
by zengargoyle (Deacon) on Mar 12, 2002 at 09:54 UTC

    Break out the bulky, slow Date::Manip.

    ... use Date::Manip; if (/>Updated: (.*?)</ && $date = ParseDate($1)) { &do_something_with($date); } else { warn "no parsum date!\n"; &fail_gracefully; }

    Date::Manip does have the advantage of parsing almost anything that can be a date.