On Thu, Oct 07, 2004 at 12:12:01PM +1000, Andrew Pam wrote:
> On Wed, Oct 06, 2004 at 02:12:58PM -0500, Ed McLain wrote:
> > my $date = `date +%F`;
> > my $hour = `date +%H`;
> > my $min = `date +%M`;
> > chomp($date);
> > chomp($hour);
> > chomp($min);
> >
> > $min =~ /([0-9])([0-9])/;
> > my $mf = $1;
> > my $ml = $2;
>
> How about this:
>
> ($sec, $min, $hour, $day) = localtime();
Sorry, to get the equivalent of "date +%F" you actually need this:
my ($sec, $min, $hour, $day, $mon, $year) = localtime();
> $ms = "0"; # Note these are strings because they are for regexp matching
> $me = "4";
> $match = sprintf("%02d %02d:%d[%s-%s]", $day, $hour, $min / 10, $ms, $me)
> print STDERR "Matching $match\n"; # Useful for debugging
> while (<LOG>) {
> print if /^$match/ and /status: /;
> }
With minor corrections:
my $ms = 0;
my $me = 4;
my $match = sprintf("%04d-%02d-%02d %02d:%d[%d-%d]", 1900 + $year, $mon, $day,
$hour, $min / 10, $ms, $me);
print STDERR "Matching '$match'\n"; # Useful for debugging
while (<LOG>) {
print if /^$match/ and /status: /;
}
Hope that helps,
Andrew
--
mailto:[EMAIL PROTECTED] Andrew Pam
http://www.xanadu.com.au/ Chief Scientist, Xanadu
http://www.glasswings.com.au/ Partner, Glass Wings
http://www.sericyb.com.au/ Manager, Serious Cybernetics