use strict; use warnings; use Benchmark 'cmpthese'; cmpthese (100000, { 'print' => sub { open my $fh, '>>', '/tmp/wp.txt' or die $!; print $fh "x\n"; close $fh; }, 'echo' => sub { system "echo x >> /tmp/we.txt"; } } ); exit;