in reply to Re^4: Returning first element of an array from a function
in thread Returning first element of an array from a function

Oooooohhhh, but that builds up an entire list for the slicing and can damage performance horrendously:

#!c:/perl/bin/perl -w $|++; use strict; use Benchmark 'timethese'; # make it so we split() into many many elements our $baz = join '', "yes.no.maybe.so." x 5000; timethese(2000, { undef => q{ ($foo, undef, $bar) = split(/\./, $baz); }, splice => q{ ($foo, $bar) = (split(/\./, $baz))[0,2]; } } ); __END__ Benchmark: timing 2000 iterations of splice, undef... splice: 101 wallclock secs (93.86 usr + 0.39 sys = 94.25 CPU) @ +21.22/s (n= 2000) undef: 0 wallclock secs ( 0.14 usr + 0.00 sys = 0.14 CPU) @ 14 +184.40/s ( n=2000) (warning: too few iterations for a reliable count)