Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Date::Manip::Recur is not returning a list

by andreas1234567 (Vicar)
on Jun 24, 2010 at 19:34 UTC ( [id://846381]=note: print w/replies, xml ) Need Help??


in reply to Date::Manip::Recur is not returning a list

It would always be a good idea to enable strict and warnings.

From looking at the tests it looks like parse returns a true/false value depending on parse success/failure, and not the actual date(s).

$ perl -l use strict; use warnings; use Date::Manip; my $obj = new Date::Manip::Recur; my $err = $obj->parse( qw(1:2:3:4*12:30:00 2000010500:00:00 2000010100:00:00 2003010100:00:00 ) ); die $obj->err() if $err; my @dates = $obj->dates(); foreach my $date (@dates) { print $date->value; } __END__ 200015123000 2001330123000 2002624123000 $
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

Replies are listed 'Best First'.
Re^2: Date::Manip::Recur is not returning a list
by desertrat (Sexton) on Jun 24, 2010 at 21:19 UTC

    Yes, $recur->parse() only parses the recurrence string, it's $recur->dates() that returns the list of dates. What I don't understand is why it isn't in my case. Clearly it worked for you.

    When I try to replicate your code example, I get something new! I'm getting a list, but instead of a list of strings it's a list of hashes...

    #!/usr/bin/perl use strict; use warnings; use Date::Manip; print "Content-type: text/html \n\n"; print "Starting....<p>"; my $freq = "0:1:0*25:0:0:0"; my $mod = "DWD"; my $sday = "Jan 1 2010"; my $eday = "Dec 30 2010"; my $bday = "Jan 1 2010"; my $recur = new Date::Manip::Recur; my $err =$recur->parse($freq,$bday,$sday,$eday); print "parse err is $err <p>"; my @date = $recur->dates(); my $datenum = @date; print "There are $datenum list members <p>"; foreach my $i (@date){ print "The date is $i->value<p>"; } exit;
    Starting.... parse err is 0 There are 12 list members The date is Date::Manip::Date=HASH(0x8404c00)->value The date is Date::Manip::Date=HASH(0x83ff830)->value ...
    headdesk
      print "The date is $i->value<p>";

      Method calls don't interpolate.  You're interpolating just the value of $i (which is an object/hashref), and the "->value" prints as is. Try

      print "The date is ", $i->value, "<p>";

        Ah, thank you sensei!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://846381]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (1)
As of 2024-04-25 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found