On Thu, Aug 18, 2011 at 08:43:05PM +0100, John Delacour wrote: > #!/usr/local/bin/perl > use strict; > my @date = localtime; > my @datearray; > $date[5] += 1900; > for (5,4,3) { > push @datearray, sprintf '%.2d', $date[$_] > } > my $date = join "-", @datearray; > while (<>) { > s~(<imported>)\d\d\d\d\-\d\d\-\d\d(</imported>)~$1$date$2~g; > print; > }
Although you add 1900 to the year, I think you forgot to add 1 to the month returned by localtime. Here are two alternate ways to format today's date: my @date = localtime; my $date = sprintf "%04d-%02d-%02d", $date[5] + 1900, $date[4] + 1, $date[3]; use POSIX qw/ strftime /; my $date = strftime "%Y-%m-%d", localtime; Ronald -- You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to bbedit@googlegroups.com To unsubscribe from this group, send email to bbedit+unsubscr...@googlegroups.com For more options, visit this group at <http://groups.google.com/group/bbedit?hl=en> If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>