#!/usr/bin/env perl use strict; use warnings; use Benchmark 'cmpthese'; my @x = qw{ABC DEF BXB}; my ($i, $c) = qw{1 B}; cmpthese 0 => { index => sub { $i == index($_, $c, $i) ? 1 : 0 for @x }, substr => sub { $c eq substr($_, $i, 1) ? 1 : 0 for @x }, };