Kevin Old wrote:
>
> On Thu, 2003-10-30 at 07:06, Rob Dixon wrote:
> > Kevin Old" wrote:
> > > Basically I'd like a hash (or whatever) that looks like this:
> > >
> > > %datepairs = (
> > > # Saturday to  Following Friday
> > > '10/11/2003' => '10/17/2003',
> > > '10/18/2003' => '10/24/2003',
> > > '10/25/2003' => '10/31/2003',
> > > '11/01/2003' => '11/07/2003',
> > > '11/08/2003' => '11/14/2003',
> > > '11/15/2003' => '11/21/2003',
> > > '11/22/2003' => '11/28/2003',
> > > );
> > >
> >
> > This seemed like a fun exercise so I wrote the program below. It builds
> > an array of eight elements, each of which is a reference to a two-element
> > array containing the start and end dates of that week. I thought that was
> > more appropriate than the tied hash you were using.
> >
> > Your specification wasn't exact so it may need some tweaking.
>
> Rob,
>
> Thanks for your help, although honestly I'm more confused.  Your output
> shows the same dates for all references in the array of dates you
> build.  I'm looking for (based on the day it's run) the past 3 week and
> next 4 week ranges from Saturday to Friday.  In my hash above, the keys
> are Saturdays and the values are their following Fridays.
>
> Thanks for your help though, I've learned about two new modules.

Sorry Kevin.

That's what comes of 'tidying up' my code after I got it working!

Change the loop to this:

  for (1 .. 8) {

    my $week;

    for my $ymd ($first, $first + 6) {
      my $mmddyyyy = sprintf "%02d/%02d/%04d", (split '-', $ymd)[1, 2, 0];
      push @$week, $mmddyyyy;
    }

    push @dates, $week;

    $first += 7;
  }

And you get this output, which is a little better!

Cheers,

Rob


@dates = (
           [
             '10/04/2003',
             '10/10/2003'
           ],
           [
             '10/11/2003',
             '10/17/2003'
           ],
           [
             '10/18/2003',
             '10/24/2003'
           ],
           [
             '10/25/2003',
             '10/31/2003'
           ],
           [
             '11/01/2003',
             '11/07/2003'
           ],
           [
             '11/08/2003',
             '11/14/2003'
           ],
           [
             '11/15/2003',
             '11/21/2003'
           ],
           [
             '11/22/2003',
             '11/28/2003'
           ]
         );



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to