#!/usr/bin/perl -w use Benchmark; use strict; my $count = shift || -3 ; # set the test counter my @array; #load up an array of crap push @array, rand(256) for 1 .. 1000; open NULL, ">/dev/null" or die $!; timethese ( $count, { 'join' => \&print_join, 'map' => \&print_map, 'list map' => \&print_map_list, 'field sep' => \&print_field, 'for' => \&print_for } ); # use join to print each array elemnet. sub print_join { print NULL join("\n", @array); } # use map to print each array elemnt, sub print_map { print NULL map{ $_ .= "\n"} @array; } # same but a no concat sub print_map_list { print NULL map { ($_, "\n") } @array; } # use map to print each array elemnt, sub print_field { local $, = "\n"; print NULL @array; } # use a loop. sub print_for { print NULL $_, "\n" for @array; }