my @acc_array; foreach(@somearray){ if($cond ==1) { my $a = Benchmark::Timer->new(skip => 0); $a->start('tag'); @acc_array = &some_long_running_func($_); $a->stop('tag'); print $a->report; } } #### Processed: 1 tag still running at mycode.pl line 223 Processed: 2 tag still running at mycode.pl line 223