#!/usr/bin/perl use strict; use warnings; use Benchmark; my $file = 'test.txt'; timethese(100, { A => sub { open ( FILE, $file ); my $ln; $ln++ while ; close (FILE); }, A2 => sub { my $ln; open ( FILE, $file ); ++$ln while ; close (FILE); }, # ist unter C ein Unterschied, spart temporäre Variable... #B => sub { # open ( FILE, $file ); # my @array; # my $ln = scalar(@array = ); # close (FILE); # }, C => sub { open ( FILE, $file ); while ( ) {} my $ln = $.; close (FILE); }, D => sub { my $ln = -s $file; }, } ); # test.txt hat 3.804.144 Zeilen und ist 195.338.421 Byte groß