Please read this site's FAQ for info on how to post. Please check the info on formatting your post. Your post is hard to read.

I'm not sure exactly what you are asking for, but it sounds like you want code that do something based on the last 31 days each day. Even if I am on the wrong track, checking out these functions should help you:

  1. time
  2. localtime
  3. Time::Local's timelocal

Now for some (untested) code.

#Loop 31 times foreach (1..31) { # Set date to $_ days in the past. my $date = time() - $_*24*60*60 my ($day,$month,$year) = localtime($date)[3,4,5]; # cleanup raw localtime output $month++; $year = substr ($year, -2); # Print niceish (whitespace instead of 0) MM/DD/YY dates to string $date = sprintf "%2d/%2d/%2d", $month,$day,$year; #I'm reusing $da +te, I don't need its old value. # Fix whitespace. $date will now hold MM/DD/YY data. $date=~s/\s/0/g; print "MM/DD/YY:\t$date\n"; }

Here's a truncated bit of output:

MM/DD/YY: 06/17/01 MM/DD/YY: 06/16/01 MM/DD/YY: 06/15/01 MM/DD/YY: 06/14/01

I hope this helps.


TGI says moo


In reply to Re: Perl Script by TGI
in thread Looping months and days by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.