#!/usr/bin/perl use strict; use Benchmark; my @text = ('+5000*', 'ein langer Text ohne solche Rechenoperationen...bla fasel laber schwaller sabbel erzähl ...', '8947573849575563542325375869676545343423232425347585764554534232432452673740-', '8947573849575563542325375869676545343423232425347585764554534232432452673740+', '8947573849575563542325375869676545343423232425347585764554534232432452673740*', '8947573849575563542325375869676545343423232425347585764554534232432452673740/', '89475738495755635423253758696765453434232324253475857645545342324324526737401', '-9475738495755635423253758696765453434232324253475857645545342324324526737401', '+9475738495755635423253758696765453434232324253475857645545342324324526737401', '*9475738495755635423253758696765453434232324253475857645545342324324526737401', '/9475738495755635423253758696765453434232324253475857645545342324324526737401', ); for my $line (@text) { print "timethesis für '$line'\n"; timethese(100000, { A => sub { if ( $line =~ m~(?:-|\+|\*|/)~) {} }, B => sub { if ( $line =~ m~-~ or m~\+~ or m~\*~ or m~/~) {} }, C => sub { if ( $line =~ m~[-+*/]~) {} }, D => sub { if ( $line =~ m~[-]~ or m~[+]~ or m~[*]~ or m~[/]~) {} }, E => sub { if (index($line, '-') > -1 or index($line, '+') > -1 or index($line, '*') > -1 or index($line, '/') > -1) {} }, }); }