#!/usr/bin/perl -w use strict; use Benchmark; timethese(1000, { 'global' => '&global', 'local' => '&local' }); sub global { my %hash; for(1..100) { for(1..10) { $hash{rand(100)} = 123; }; } %hash=(); } sub local { for(1..100) { my %hash; for(1..10) { $hash{rand(100)} = 123; }; } } #### Benchmark: timing 1000 iterations of global, local... global: 14 wallclock secs (13.47 usr + 0.01 sys = 13.48 CPU) local: 14 wallclock secs (13.33 usr + 0.02 sys = 13.35 CPU)