#!/usr/bin/perl print '',( `acpi` =~ /(\d+)%/ )[ 0 ] // '??', "%"; #### #!/usr/bin/perl #battery.pl use strict; use warnings; use 5.012; my $battery_charge; $battery_charge = `acpi`; if($battery_charge =~ /\d{2}%/ ) { print "Battery: $&\n"; }