Second cut -- DBus! 

use Net::DBus;
my $bus = Net::DBus->system;
my $hal = $bus->get_service("org.freedesktop.Hal");
my $man = 
  $hal->get_object(
    "/org/freedesktop/Hal/Manager", 
    "org.freedesktop.Hal.Manager"
  );
my $batteries = $man->FindDeviceByCapability("battery");
my $battery;
for (@{$batteries}) {
  my $o = $hal->get_object($_, 'org.freedesktop.Hal.Device');
  if ($o->GetPropertyBoolean('battery.present')) {
    $battery = $o;
    last;
  }
}