Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > yesterday's tim...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 10887 of 11992
Post > Topic >>

yesterday's time

by rich.japh@[EMAIL PROTECTED] (Richard Lee) Apr 7, 2008 at 12:20 AM

I just read FAQ on finding out yesterday's time.

I see that one of the easy way to find out is

my $date = scalar localtime( ( time() - ( 24 * 60 * 60 ) ) );
print "$date\n";

and it works fine for me

I also see lot of modules that will make life easier for beginners.. but 
since I was learning reference, I wanted to try this on my own
since Leap year is not a huge factor, so

my @[EMAIL PROTECTED]
 = (1..31);
my @[EMAIL PROTECTED]
 = (1..29);
my @[EMAIL PROTECTED]
 = (1..31);
my @[EMAIL PROTECTED]
 = (1..30);
my @[EMAIL PROTECTED]
 = (1..31);
my @[EMAIL PROTECTED]
 = (1..30);
my @[EMAIL PROTECTED]
 = (1..31);
my @[EMAIL PROTECTED]
 = (1..31);
my @[EMAIL PROTECTED]
 = (1..30);
my @[EMAIL PROTECTED]
 = (1..31);
my @[EMAIL PROTECTED]
 = (1..30);
my @[EMAIL PROTECTED]
 = (1..31);

my @[EMAIL PROTECTED]
 = [ @[EMAIL PROTECTED]
 my $i ( 0 .. $#cal_r ) {
    for my $j ( 0 .. $#{ $cal_r[ $i ] } ) {
           print "$cal_r[ $i ][ $j ]\n";
    }
}

and then just check to see if it's first day of the month and if it is, 
go through @[EMAIL PROTECTED]
 and find the previous month and find the last array
item..
Algorithm seems to be correct but I cannot get to the item the way I 
thought I could.

What would be the correct syntax if I knew the date? say Apr 1st to find 
the yesterday's date given above?

I was thinking something along the line of

for my $i ( 0 .. $#cal_r ) {
    if ($cal_r[$i][0]) {
          print "yesterday is $cal_r[$i-1][lastday]\n"
    }
}
 




 3 Posts in Topic:
yesterday's time
rich.japh@[EMAIL PROTECTE  2008-04-07 00:20:29 
Re: yesterday's time
Jim Gibson <jimsgibson  2008-04-07 11:14:15 
Re: yesterday's time
rich.japh@[EMAIL PROTECTE  2008-04-08 01:29:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 11:19:05 CDT 2008.