Subject: | Patch for a successfully string matching and value assignment |
Date: | Mon, 19 Jan 2009 12:57:34 -0200 |
To: | bug-Unix-Uptime [...] rt.cpan.org |
From: | "Murilo Opsfelder Araújo" <mopsfelder [...] gmail.com> |
Hello Mike Kelly,
I was facing problems with Unix::Uptime on my FreeBSD box [1]. So, I
tried this patch [2] against Uptime.pm and now it seems to be ok.
The comparison was not returning the correct boot seconds, but 1 for a
successfully string match and 0 for a failed string match.
I hope you enjoy the patch [2] and, please, let me know about any suggestions.
[1]
FreeBSD opsfelderm.bplab.local 8.0-CURRENT FreeBSD 8.0-CURRENT #37
r187296: Thu Jan 15 10:08:42 BRST 2009
root@opsfelderm.bplab.local:/usr/obj/usr/src/sys/PANDA i386
[2]
diff -ruN Unix-Uptime-0.1.orig/lib/Unix/Uptime.pm
Unix-Uptime-0.1/lib/Unix/Uptime.pm
--- Unix-Uptime-0.1.orig/lib/Unix/Uptime.pm 2008-12-08 19:09:32.000000000 -0200
+++ Unix-Uptime-0.1/lib/Unix/Uptime.pm 2009-01-19 12:41:15.000000000 -0200
@@ -62,7 +62,8 @@
my $class = shift;
my $boottime = `sysctl kern.boottime`;
- my $boot_seconds = $boottime =~ /\s+sec\s+=\s+(\d+),/;
+ $boottime =~ /\s+sec\s+=\s+(\d+),/;
+ my $boot_seconds = $1;
my $time = time();
my $uptime = $time - $boot_seconds;
return $uptime;
[3] $ perl -v
This is perl, v5.8.8 built for i386-freebsd
(with 1 registered patch, see perl -V for more detail)
Best regards.
--
Murilo Opsfelder Araujo
mopsfelder@gmail.com
{murilo,panda}@bsd.com.br
BSD will never die.