#!/usr/bin/perl use strict; use warnings; use Benchmark qw(cmpthese timethese); sub tp_map { my $i; my $pos = tell DATA; while () { chomp; chop; s/\?'/'/g; $i = 0; map { '['.$i++."]$_\n" } split(/\+/); } seek DATA, $pos, 0; } sub tp_for { my $i; my $pos = tell DATA; while () { chomp; chop; s/\?'/'/g; $i = 0; '['.$i++."]$_\n" for split(/\+/); } seek DATA, $pos, 0; } cmpthese timethese(-2, { tp_map => \&tp_map, tp_for => \&tp_for, }); __DATA__ 0010+2+O?'Reilly' 012+90+Penguin'