#!/usr/bin/perl -w use strict; use Benchmark qw(cmpthese); my $i=0; my @spin=qw(- \\ | /); sub spinShift { my $spin=shift @spin; push @spin,$spin; return $spin; } my $ndx=0; sub spinNdx { return $spin[$ndx++ % @spin]; } cmpthese(-2, { spinShift => \&spinShift, spinNdx => \&spinNdx, } );