HTTP::Date parse_date problem

P

Paul Tomlinson

use HTTP::Date
.....
my ($year, $month, $day, $hour, $min, $sec, $tz) = parse_date(time2str());

why doesn't this work???

It's driving me mad, does this look like valid perl?
 
G

Glenn Jackman

Paul Tomlinson said:
use HTTP::Date
....
my ($year, $month, $day, $hour, $min, $sec, $tz) = parse_date(time2str());

why doesn't this work???

Note how the HTTP::Date documentation says: "Only the first two
functions, time2str() and str2time(), are exported by default."

So:
my (...) = HTTP::Date::parse_date(time2str());

or
use HTTP::Date qw(parse_date time2str);
my (...) = parse_date(time2str());
 
G

Glenn Jackman

Glenn Jackman said:
Note how the HTTP::Date documentation says: "Only the first two
functions, time2str() and str2time(), are exported by default."

use HTTP::Date qw(parse_date time2str);

Upon reflection, this would be preferable:

use HTTP::Date qw:)DEFAULT parse_date);
 
J

John Strauss

use HTTP::Date
....
my ($year, $month, $day, $hour, $min, $sec, $tz) = parse_date(time2str());

why doesn't this work???

It's driving me mad, does this look like valid perl?

apart from the missing semicolon on the "use HTTP::Date" line,
it looks like valid perl.

otherwise the HTTP::Date docs state that parse_date() is not
exported by default. try HTTP::Date::parse_date instead.
 
G

Gunnar Hjalmarsson

Paul said:
use HTTP::Date
....
my ($year, $month, $day, $hour, $min, $sec, $tz)
= parse_date(time2str());

why doesn't this work???

Why did you post the question without letting us know which error
message it results in??

When testing it I got:
"Undefined subroutine &main::parse_date called at ..."

So, I checked the documentation... The rest is explained in Mothra's
message.
 
M

Mothra

Hi Paul,

Paul Tomlinson said:
use HTTP::Date
....
my ($year, $month, $day, $hour, $min, $sec, $tz) = parse_date(time2str());

why doesn't this work???

It's driving me mad, does this look like valid perl?
yep! it is valid perl :)
after checking the docs for this I found

This module provides functions that deal the date formats used by the
HTTP protocol (and then some more). Only the first two functions,
time2str() and str2time(), are exported by default.

So, you need to do something like
use HTTP::Date qw(parse_date time2str);

hope this helps

Mothra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top