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";