for my $delta ($delta_time, $delta_date){ # the above are likely to be Date::Manip[::*] objects - which ones???? for my $field (qw (seconds minutes hours days months years)) { for my $type ('','total_') { my $func = "${type}${field}"; # this is the method name to be called via the $delta objects for my $prec ('','trunc') { # this is the a parameter to above method, one is empty one is 'trunc' diag ("comapring ".$delta->$func($prec)." to ".$test_values[$test_index]." at ".$test_index." func=".$func." prec=".$prec." type=".$type." field=".$field); ok($delta->$func($prec) == $test_values[$test_index++],"$func($prec) ($delta_text[$delta_index])") # it calls e.g. this: $delta->total_seconds('trunc') # and it compares the returned result with an item from an array # of expected results $test_values[$test_index]