in reply to pattern matching

Another way which may prove to be other a better alternative is to read the uptime directly from /proc/uptime (assuming that this interface is available to you) - This allows for vagarities of uptime output and regular pattern matching to sidestepped altogether.

For example:

use Date::Calc qw/ Normalize_DHMS /; use IO::File; # get_uptime function - returns uptime from /proc/uptime # as 4-member array representing current system uptime in # days, hours, minutes and seconds sub get_uptime { my $uptime; my $fh = IO::File->new('/proc/uptime', 'r'); $uptime = (split /\s+/, <$fh>)[0] if defined $fh; return Normalize_DHMS(0, 0, 0, $uptime) if defined $uptime; }