Recently in perl Category
Scenario: you want to convert "2008-08-02 12:45:01" to the unix epoch time:
use Time::Local qw/timegm/; my $dt = "2008-08-02 12:45:01"; my @datetime = split /\-|:|\s/, $dt; $datetime[1]--; # months need decrementing my $epoch_time = timegm(reverse @datetime);
Imagine the scenario: you have a hash of arguments you want to send as a CGI query string to somewhere on the web. Or you might, for instance, need to create an unsubscribe URL to include in your newsletter emails so that people can click a link to stop getting your newsletter.
Here's a one line solution:
my %args = (
id => 102546,
key => 'kljdlasjd3289290mkdlmca',
list => 12,
action => 'unsubcribe',
);
my $query_string = join '&', map { "$_=$args{$_}" } keys %args;
my $url = "http://example.com/newsletter?$query_string";
That should create your query string out of all the elements of your hash.
Okay, so the idea is pretty simple: to have a means to install CPAN modules via your web browser. A few attempts later and I have created CPAN::Web - a little CGI based web application that uses CPANPLUS to do the main work.
Hopefully it should just work once you extract the files. I know it probably won't and people will have issues with it, so please, please do make suggestions, check out the source and mess about with and generally help make it better. Who knows, maybe it will be a Good Thing some day?
