Sven Bentlage wrote:
>
> Encountered another problem:
>
> I'm trying to use a calculated date value in a regex. It only works with
> values which are NOT calculated.
>
> my ($dc, $mc, $yc) = (localtime(time))[3,4,5];
> my $date_now = sprintf("%02d-%02d-%02d", $dc, $mc+1, $yc-100);
^^^^^^^
> my ($da, $ma, $ya) = (localtime (time + (ONE_DAY)))[3,4,5];
> my $next_date = sprintf("%02d-%02d-%02d", $da, $ma+1, $ya-100);
^^^^^^^
Use $year % 100 instead of subtracting 100.
> using $date_now in this regex works:
>
> while ( <APODATA> ) {
> ( $date_today, $aponame, $apoaddress, $apotel ) = split(/:/,$_);
> my @data = split(/:/);
Any reason that you are splitting $_ twice?
> foreach ($data[0]) {
Any reason that you are looping over a single scalar?
> if (/$date_now/) {
Maybe you should use eq instead of a regular expression.
> print "$date_now\n";
> print "$next_date\n";
> }
> }
^
Missing the while loop end brace.
>
> if I replace $date_now with $next_date I get an error message (premature
> end of script headers).
They are both formatted the same so they should both work.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]