sub get_acpi_info { open P, "-|", "/usr/bin/acpi -a -b"; my $acpi_string = join '', <P>; close P; my ($charge) = ($acpi_string =~ m{(\d+)%}); my ($remaining) = ($acpi_string =~ m{(\d\d:\d\d:\d\d)}); $acpi_string =~ /on-line/ ? "$charge% online" : "$charge% $remaining"; }