On Tue, Aug 3, 2010 at 08:44, Shawn H Corey <shawnhco...@gmail.com> wrote: > On 10-08-03 06:43 AM, Rob Coops wrote: >> >> Third you could of course when you are printing the values from the array >> add the linefeeds: >> print join("\n", @myarray); >> or >> foreach my $value ( @myarray ) { >> print $value . "\n"; > > When printing, use a list; it's faster. > > print $value, "\n"; snip
I hate it when some makes a blanket statement of "it's faster" without providing a benchmark or a reason. In the simple case, the comma is slower than the period and interpolation is slower still. One item: #!/usr/bin/perl use strict; use warnings; use Benchmark; open my $bit_bucket, ">", "/dev/null" or die "$!"; my $s = "foo"; my %subs = ( string => sub { print $bit_bucket "$s\n" }, comma => sub { print $bit_bucket $s, "\n" }, period => sub { print $bit_bucket $s . "\n" }, ); for my $sub (keys %subs) { print "$sub: ", $subs{$sub}(), "\n"; } Benchmark::cmpthese -1, \%subs; Ten Items: -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/