in reply to Re^2: Calculating the time to execute commands on each element of an array
in thread Calculating the time to execute commands on each element of an array

I don't have the time at the moment to go through it all line-by-line, but after a quick glance, it appears that you can move most of that code as-is to a new sub, then call it like this:

for my $FQDN (@things){ my $start_time = time_and_log($FQDN); # do stuff with $FQDN time_and_log($FQDN, $start_time); }

...and in the sub...

sub time_and_log { my $FQDN = shift; my $start = shift; if (! $start){ # do start stuff $start = time; return $start; } else { # use $start for calculations, # then log } }