You want to use the Trim() method, followed by resetting the page attribute. Trim will crop off all of the image that is exactly the same color as the corner pixels (in your case transparent). Resetting the page attribute will make sure your content is properly aligned on the new, smaller image canvas.
Here's some more info on Trim() from the documentation for ImageMagick: http://www.imagemagick.org/script/command-line-options.php#trim
And here it is in the list of valid image manipulation methods in PerlMagick (though the documentation here is a bit sparser): http://www.imagemagick.org/script/perl-magick.php#manipulate
Something like the following should do the trick for you:
use strict;
use Image::Magick;
my $in = $ARGV[0];
my $out = $ARGV[1];
my $transparent_png = Image::Magick->new;
$transparent_png->Read("$in");
$transparent_png->Trim();
$transparent_png->Set(page=>'0x0+0+0');
$transparent_png->Write("$out");