Pagoda wrote:
> 
> Can I improve the performance of script by using constant?

You can use the Benchmark module to test the performance of different
options.

> Which is the better one?
> 
> use constant const => 1e-12
> 
> or
> 
> my $const = 1e-12

use works at compile time and replaces the constant name with the
constant value so it should be faster.

$ perl -MO=Deparse -le' use constant one => 1e-12; print one '

sub one () {
    package constant;
    $scalar;
}
print 1e-12;

-e syntax OK



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to