I'm trying to use Date::Manip::Recur to generate a list of dates for a room scheduling application, and I'm having trouble getting it to work correctly.

Per the docs, there's an OO way and a functional way of doing this.

The functional way works:

#!/usr/bin/perl use Date::Manip; @date = ParseRecur("0:0:1*1,3,5:0:0:0","May 25 2010","6/1/2010","8/30/ +2010");# every MWF between the two dates. foreach $i (@date){ print "The date is $i\n"; } exit;

results in:

The date is 2010060200:00:00 The date is 2010060400:00:00 The date is 2010060700:00:00 The date is 2010060900:00:00 The date is 2010061100:00:00 The date is 2010061400:00:00 The date is 2010061600:00:00 The date is 2010061800:00:00 The date is 2010062100:00:00

and so on.

But

#!/usr/bin/perl use Date::Manip; print "Starting....\n"; $recur = new Date::Manip::Recur; $start = $recur->new_date(); $end = $recur->new_date(); $base = $recur->new_date(); $err=$start->parse("Jun 1 2010"); print "start err is $err \n"; $err=$end->parse("Aug 30 2010"); print "end err is $err \n"; $err=$base->parse("May 25 2010"); print "base err is $err \n"; $err=$recur->frequency("0:0:1*1,3,5:0:0:0"); print "freq err is $err \n"; @date = $recur->dates(); print "dates err is $err \n"; foreach $i (@date){ print "The date is $i\n"; } exit;

gives me:

Starting.... start err is 0 end err is 0 base err is 0 freq err is 0 dates err is 0

And nothing more.

I cannot even get the OO example given in the docs to work.

anyone here used this, and can point out my no doubt boneheaded mistake, before I bug the author?


In reply to Date::Manip::Recur is not returning a list by desertrat

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.