use strict; use warnings; use Benchmark; my $tmp_line = 'x' x 18_000; open my $frontend, '>>', '/dev/null' or die $!; Benchmark::cmpthese(-1, { _regex => \&_regex, _unpack1 => \&_unpack1, _unpack2 => \&_unpack2 }); sub _regex { if( length $tmp_line < 4000 ){ $tmp_line .= "\t" x 5; } else{ $tmp_line =~ s/(.{4000})/$1\t/g; } print $frontend $tmp_line; } sub _unpack1 { my $laenge = length($tmp_line); if($laenge <=4000) { print $frontend "$tmp_line\t\t\t\t\n"; } elsif($laenge <= 8000) { my ($a, $b) = unpack("A4000 A4000", $tmp_line); print $frontend "$a\t$b\t\t\t\n"; } elsif($laenge <= 12000) { my ($a, $b, $c) = unpack("A4000 A4000 A4000", $tmp_line); print $frontend "$a\t$b\t$c\t\t\n"; } elsif($laenge <= 16000) { my ($a, $b, $c, $d) = unpack("A4000 A4000 A4000 A4000", $tmp_line); print $frontend "$a\t$b\t$c\t$d\t\n"; } } sub _unpack2 { my $len = length($tmp_line); my $pos = 0; my $tab = 5; while ( my $s = unpack("x$pos A4000", $tmp_line) ) { $tab--; print $frontend "$s\t"; $pos += 4000; last if $pos >= $len; } print $frontend "\t" x $tab; print $frontend "\n"; }