my $last_in_sentence = sub {return $content_array[$loc] =~ m/\.$/}; [...] if (&$last_in_sentence) { [...] }