my $str_a = 'Foo'; # Can be any length for my $str_b (grep /^$str_a/, @list ) { # Can be any number of items expensive_function($str_a , $str_b); }