Keith Devens .com |
Saturday, November 22, 2008 | ![]() |
| Darwin made it possible to be an intellectually-fulfilled atheist. – Richard Dawkins (The Blind Watchmaker) | ||
|
| ← How Pixar Adds a New School of Thought to Disney - New York Times | reform - Third millenium syntax for Perl 5 OOP → |

Joseph Scott (http://joseph.randomnetworks.com/) wrote:
Keith (http://keithdevens.com/) wrote:
Yeah, it would. And it even worked fine on the date format I just had to parse:
$ php -r "echo date('c',strtotime('02/01/2006,12:06:04am'));"
2006-02-01T00:06:04-06:00
(hey, central time zone
)
But, I was working in Perl, and there are no built-in date parsing libraries in Perl.
Joseph Scott (http://joseph.randomnetworks.com/) wrote:
I couldn't find a strtotime() for Perl, but CPAN has Date::Manip and Time::Format that should do it (I think).
Keith (http://keithdevens.com/) wrote:
Yeah, CPAN has some things, but unfortunately there's nothing standard.
Aidan Kehoe (http://www.parhasard.net/) wrote:
use Date::Parse qw/str2time/; for the next time that comes up ...
Keith (http://keithdevens.com/) wrote:
Of course, but like I said, there's nothing standard:
C:\temp>cat test.pl
use Date::Parse qw/str2time/;
print "hello";
C:\temp>test.pl
Can't locate Date/Parse.pm in @INC (@INC contains:
C:/Perl/lib C:/Perl/site/lib .) at C:\temp\test.pl line 1.
BEGIN failed--compilation aborted at C:\temp\test.pl line 1.
(wrapped so it doesn't break my layout) BTW, I don't think I ever linked this article on handling dates and times with Perl, but I think that was one of the things I looked through. Point was, I couldn't go installing modules on the server I was working on.
Aidan Kehoe (http://www.parhasard.net/) wrote:
Ah, right. Yeah, Perl's a signficantly suckier language when you can't install modules; I wrote this earlier today, for example, and I'm not proud of it:
# We need an actual file to pass to the openssl command-line
# tool. Create it using the Perl temporary file module.
my ($temp_file_handle, $temp_file_name)
= tempfile DIR => $tempdir;
# Flush writes to the file that we're going to hash
# automatically.
$| = 1, select $_ for select $temp_file_handle;
# Write the secret prefix and the content to the file, so the hash
# operation takes place on the same string on both ends
print { $temp_file_handle } SIGNING_PREFIX.$content;
close $temp_file_handle;
my $hash = `/usr/bin/openssl dgst -sha1 < $temp_file_name`;
unlink $temp_file_name;
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):
Generated in about 0.231s.
(Used 8 db queries)

Will strtotime() work for this?