#!/usr/bin/perl -w use strict; use vars qw(@array); @array = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); use vars qw($test); if ($ARGV[0] eq "1") { $test = sub { print "Found!\n" if index("@array", $_[0]) > 1; } } elsif ($ARGV[0] eq "2") { $test = sub { print "Found!\n" if grep { $_ eq $_[0] } @array; } } else { die "Usage: $0 1|2\n"; } for(my $i=0;$i<1_000_000;$i++) { &$test(chr(ord('m') + ($i % 26))); }