#!/usr/bin/perl use strict; # this is the hash I want to keep results in my %count = (); # there are way more lines than this but anyway... for my $i (1 .. 100){ # this just represents that I've found a pair and want to run the sub if ($i % 50 == 0){ # run the sub &inc(\%count); } } # I need access to the hash that's updated in the sub print $count{'count'}."\n"; sub inc { my $c = shift; # make a change to the hash $c->{'count'}++; # pausing for affect! # this simulates that the sub takes a while to run sleep(10); }