#!/usr/bin/perl # don't leave home without these two use strict; use warnings; # get time the perl-way (use gmtime instead of localtime for UTC) # http://perldoc.perl.org/functions/localtime.html # (the brackets around time are optional) my @fields = localtime(time); # extract the relevant values # the 'dumb' way - single scalars #my $day = $fields[3]; #my $month = $fields[4]; #my $year = $fields[5]; # the smart way - array slice my ($day, $month, $year) = @fields[3,4,5]; # add required offsets $month++; $year += 1900; # use format codes to zero-pad the month and day values (and also the # year - just to be sure; replace 'tar' and 'gz' with '%s'-format code # and a variable if you need them to be dynamic) my $dbfile = sprintf 'bugs_db_%04i-%02i-%02i.gz', $year, $month, $day; my $webfile = sprintf 'bugzilla_%04i-%02i-%02i.tar.gz', $year, $month, $day; print "Database file: $dbfile\n"; print "Archive: $webfile\n"; exit;