#### LISTING ONE #### package Acme::Current; use strict; use vars qw($VERSION); use vars qw($YEAR $MONTH $DAY); $VERSION = sprintf "%04d%02d%02d", $YEAR = 2003, $MONTH = 7, $DAY = 20; 1; __END__ =head1 NAME Acme::Current - Determine current year, month, day (GMT) =head1 SYNOPSIS use Acme::Current; printf "It's now %04d/%02d/%02d.\n", $Acme::Current::YEAR, $Acme::Current::MONTH, $Acme::Current::DAY; if ($Acme::Current::MONTH == 12 and $Acme::Current::DAY == 25) { print "Merry Christmas!\n"; } ..... REST OMITTED ..... #### LISTING TWO #### use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Acme::Current', VERSION_FROM => 'lib/Acme/Current.pm', PREREQ_PM => { 'Test::More' => 0, }, ); #### LISTING THREE #### use Test::More qw(no_plan); BEGIN { use_ok('Acme::Current'); } my @now = gmtime; is($Acme::Current::YEAR, $now[5]+1900, 'year'); is($Acme::Current::MONTH, $now[4]+1, 'month'); is($Acme::Current::DAY, $now[3], 'day'); #### LISTING FOUR #### README Makefile.PL MANIFEST This list of files lib/Acme/Current.pm t/01-core.t #### LISTING FIVE #### Acme::Current gives you all the power of those myriad of date/time modules without all that complexity, as long as all you want is the current date (GMT-based), and you keep the module up to date. #### LISTING SIX #### #!/usr/bin/perl use strict; $|++; use FindBin qw($Bin); BEGIN { chdir $Bin or die "Cannot chdir to $Bin: $!" } use WWW::Mechanize; use File::Copy; my $CPAN_DIR = "/web/private/CPAN"; my $CPAN_URI = "http://www.stonehenge.comm/private/CPAN"; my $CPAN_USER = "merlyn"; chomp(my $CPAN_PASSWORD = ); my @now = gmtime; my ($Y, $M, $D) = ($now[5]+1900, $now[4]+1, $now[3]); { local @ARGV = "lib/Acme/Current.pm"; local $^I = "~"; while (<>) { s/\$YEAR = \d+, \$MONTH = \d+, \$DAY = \d+;/\$YEAR = $Y, \$MONTH = $M, \$DAY = $D;/; print; } } system "perl Makefile.PL >/dev/null && make all test tardist /dev/null 2>&1"; unlink glob "*.tar"; # in case it blocked from a .gz submit_to_cpan($_) for glob "Acme-Current-*.tar.gz"; sub submit_to_cpan { my $local_file = shift; my $cpan_dir_file = "$CPAN_DIR/$local_file"; return if -f $cpan_dir_file; # already submitted; copy $local_file, $cpan_dir_file; my $agent = WWW::Mechanize->new(); $agent->credentials('pause.perl.org:443', 'PAUSE', $CPAN_USER, $CPAN_PASSWORD); $agent->get('https://pause.perl.org'); $agent->follow(qr/Login/); $agent->follow(qr/Upload a file/); $agent->current_form->value('pause99_add_uri_uri', "$CPAN_URI/$local_file"); $agent->click('SUBMIT_pause99_add_uri_uri'); print "$local_file submitted\n"; ### print $agent->current_form->dump; }