use strict; use warnings; use autodie; my $length; my $file = 'the filename...'; open(my $fh, '<', $file) || die "cant open file\n"; while (<$fh>) { chomp; my($target, $mirna, $score, $start) = split(/\s+/); print join("\t", $mirna, $target, $start, $score), "\n"; $length = $.; } close $fh;