Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > Miscellaneous > Archive > Sitescooper

Notices

 
 
Thread Tools Search this Thread
Old 03-16-2004, 10:36 PM   #1
ignatz
mechanoholic
ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.
 
ignatz's Avatar
 
Posts: 582
Karma: 1000217
Join Date: Mar 2004
Location: Sarasota, FL
Device: Nook STR/iPhone 4S/EVO 4G
perl help! - trying to use timelocal within URLProcess

I am completing some modifications to my New York Times scoop. Because the NYT archives their content after 10 days, the printer friendly links that I use in my scoop no longer work after that time. In most cases the pages scooped are still fine, but other times they are split into parts and the following pages are not downloaded (even with StoryFollowLinks turned on... not sure why). So I am trying to add a routine in URLProcess that will analyze the date of the story, present in the URL, and drop the story from the scoop if it is older than 10 days. My code works except for a function call to timelocal.pl that is not recognized. I get this error:
SITE WARNING: "NYTimes.site" line 7: URLProcess failed: Undefined subroutine
&Sitescooper::URLProcessor::timelocal called at (eval 23) line 1.
I have no perl experience and am just hacking this thing together as I go.
I cannot figure out how to resolve this. I tried adding the "require
'timelocal.pl'" command to "Main.pm" and to "StoryURLProcessor.pm", but that
didn't help either. Can someone help me? Below is the URLProcess code that
I'm using.

URLProcess: {
#Check for stories that are older than 10 days
#The printable page version won't work for these
#Currently they are just ignored
#Who needs news older than 10 days anyway?
require 'timelocal.pl';
my $url = $_;
my $y = index($url,"200");
my $year = substr($url,$y,4);
my $month = substr($url,$y+5,2);
my $day = substr($url,$y+8,2);
#my $giventime = timelocal(0,0,0,$day,$month-1,$year);
#my $currenttime = timelocal(0,0,0,(localtime) [3,4,5]);
if ((timelocal(0,0,0,(localtime) [3,4,5]) -
timelocal(0,0,0,$day,$month-1,$year)) > 10*24*3600) {
$_ = undef};
}

This code works well in testing outside of Sitescooper. I'm certain that there is a way to define the call that the program will like. Can anyone clue me in? I have also posted to the Sitescooper mailing list, but traffic there is very light of late... Thanks.
ignatz is offline  
Old 03-17-2004, 10:16 AM   #2
TadW
Uebermensch
TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.TadW ought to be getting tired of karma fortunes by now.
 
TadW's Avatar
 
Posts: 2,583
Karma: 1094606
Join Date: Jul 2003
Location: Italy
Device: Kindle
ignatz,

why are you using timelocal.pl to perform your date/time calculations? Anyways, the timelocal() function is defined in the Time::Local module. So you should try it with

use Time::Local;

instead of

require 'timelocal.pl';

Tell me if that helps.
TadW is offline  
Advert
Old 03-17-2004, 11:01 AM   #3
ignatz
mechanoholic
ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.
 
ignatz's Avatar
 
Posts: 582
Karma: 1000217
Join Date: Mar 2004
Location: Sarasota, FL
Device: Nook STR/iPhone 4S/EVO 4G
Quote:
Originally Posted by TadW
why are you using timelocal.pl to perform your date/time calculations?
Because I don't know perl! If there's a better way please tell me. All I'm trying to do is compare two dates and check if the URL date is older than 10 days from the current date. Timelocal is what I stumbled on to do it. As I said, I'm just hacking this script together, using web references, etc.

That said, I did try using "use Time::local" on some standalone sample files that I ran to test the code and I would get an "unknown module" error or something. When I included "require 'timlocal.pl'" it worked. I will try changing the code to "use..." and see what happens.

But if you have another method, please tell me! Thanks.
ignatz is offline  
Old 03-17-2004, 11:05 AM   #4
ignatz
mechanoholic
ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.
 
ignatz's Avatar
 
Posts: 582
Karma: 1000217
Join Date: Mar 2004
Location: Sarasota, FL
Device: Nook STR/iPhone 4S/EVO 4G
BTW, I'm using ActivePerl on WinXP if that makes any difference...
ignatz is offline  
Old 03-19-2004, 07:26 AM   #5
ignatz
mechanoholic
ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.ignatz ought to be getting tired of karma fortunes by now.
 
ignatz's Avatar
 
Posts: 582
Karma: 1000217
Join Date: Mar 2004
Location: Sarasota, FL
Device: Nook STR/iPhone 4S/EVO 4G
TadW, I finally had a chance to try it with "use Time::local". It still failed but the errors were slightly changed. I saw this:
SITE START: now scooping site "sites/NYTimes.site".
Subroutine _daygm redefined at C:/Perl/lib/Time/local.pm line 53.
Subroutine _timegm redefined at C:/Perl/lib/Time/local.pm line 62.
Subroutine timegm redefined at C:/Perl/lib/Time/local.pm line 71.
Subroutine timegm_nocheck redefined at C:/Perl/lib/Time/local.pm line 113.
Subroutine timelocal redefined at C:/Perl/lib/Time/local.pm line 119.
Subroutine timelocal_nocheck redefined at C:/Perl/lib/Time/local.pm line 151.
SITE WARNING: "NYTimes.site" line 7: URLProcess failed: Undefined subroutine &Si
tescooper::URLProcessor::timelocal called at (eval 23) line 1.
The final failure message makes me think that there is a problem in the way that timelocal is called, but I don't know enough to diagnose. I'll have to try adding "use Time::local" in the main body of the program (Main.pm, or perhaps StoryURLProcessor.pm) and see if that makes any difference.

Do you have any other ways to do this calculation? It seemed easiest to convert to epoch time to avoid the confusion over number of days in a month, etc. But if there is some way to do it without using an add-on module, perhaps it won't fail...

Thanks.
ignatz is offline  
Advert
 


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl and Regex Alexander Turcic Lounge 3 01-25-2011 07:48 PM
Any good Perl scripters out there? Goshzilla Workshop 28 04-09-2010 02:55 PM
perl for the DR800/DR1000? Mr. X iRex 1 03-16-2010 07:47 AM
Perl processing alexxxm Sony Reader 3 11-26-2007 06:13 AM
Any perl or python gurus? jbenny Workshop 0 11-23-2007 03:27 PM


All times are GMT -4. The time now is 08:57 AM.


MobileRead.com is a privately owned, operated and funded community.