Hi, welcome to Perl, and welcome to PerlMonks
If you haven't yet heard of it, now's the time to check out the
CPAN, where you can get pre-built and pre-tested
1 modules to do common tasks. A quick trawl through the Math:: namespace revealed the
Math::SigFigs module, which, once installed, can be used like this:
#!/usr/bin/perl
use warnings;
use strict;
use Math::SigFigs;
my $num = 123.456;
print FormatSigFigs($num,1), "\n";
1. Don't underestimate the importance of the tested status. The modules will (usually) have been used by many people, on many platforms, and problems will hopefully have been reported back to the module author and fixed. You'll hear many people saying "Don't re-invent the wheel"; testing is just one reason why not.
Is this going out live?
No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist