P
Peter Jamieson
Hi all,
I collect data from a web site at irregular intervals using a script
part of which is below. In the code snippet shown I manually
insert date values for $from_date and $to_date, save and close the
script then run it from the command line.
I would like to avoid the manual step of entering the $from_date and
$to_date
values, instead have the code determine them for me based on a couple of
rules:
1. The $to_date is always "yesterday" ie the day before the current date
2. The $from_date is always the day after the previous $to_date, that is
the $to_date used when the script was previously run....the idea being
as time passes to cover all dates.
For example if $from_date = '2007/10/13' and $to_date = '2007/10/15'
and the script was run then if I want to run the script today, 2007/10/18
I need the script to set $from_date = '2007/10/16' and $to_date =
'2007/10/17'
I *think* I need to store the most recently completed date range within the
script
somehow and then update it after each run or before each new but cannot see
how.
Hope this makes sense!....any suggestions appreciated...cheers, Peter
#!/usr/bin/perl -w
use strict;
use warnings;
use HTTP::Cookies;
use LWP;
use Time::Local;
use Win32::ODBC;
my($db) = new Win32::ODBC('expenses');
# YYYY/MM/DD format
my $from_date = '2007/10/13';
my $to_date = '2007/10/15';
my ($from_year, $from_mon, $from_day) = split('/', $from_date);
my ($to_year, $to_mon, $to_day) = split('/', $to_date);
my $from_datetime = timelocal(0,0,0,$from_day,$from_mon-1,$from_year);
my $to_datetime = timelocal(0,0,0,$to_day,$to_mon-1,$to_year);
# snipped rest of Perl script to collect data for the stipulated date
range......
I collect data from a web site at irregular intervals using a script
part of which is below. In the code snippet shown I manually
insert date values for $from_date and $to_date, save and close the
script then run it from the command line.
I would like to avoid the manual step of entering the $from_date and
$to_date
values, instead have the code determine them for me based on a couple of
rules:
1. The $to_date is always "yesterday" ie the day before the current date
2. The $from_date is always the day after the previous $to_date, that is
the $to_date used when the script was previously run....the idea being
as time passes to cover all dates.
For example if $from_date = '2007/10/13' and $to_date = '2007/10/15'
and the script was run then if I want to run the script today, 2007/10/18
I need the script to set $from_date = '2007/10/16' and $to_date =
'2007/10/17'
I *think* I need to store the most recently completed date range within the
script
somehow and then update it after each run or before each new but cannot see
how.
Hope this makes sense!....any suggestions appreciated...cheers, Peter
#!/usr/bin/perl -w
use strict;
use warnings;
use HTTP::Cookies;
use LWP;
use Time::Local;
use Win32::ODBC;
my($db) = new Win32::ODBC('expenses');
# YYYY/MM/DD format
my $from_date = '2007/10/13';
my $to_date = '2007/10/15';
my ($from_year, $from_mon, $from_day) = split('/', $from_date);
my ($to_year, $to_mon, $to_day) = split('/', $to_date);
my $from_datetime = timelocal(0,0,0,$from_day,$from_mon-1,$from_year);
my $to_datetime = timelocal(0,0,0,$to_day,$to_mon-1,$to_year);
# snipped rest of Perl script to collect data for the stipulated date
range......