#!/usr/bin/perl use warnings; use strict; my $infile = "VelocityPlot.dem"; my $outfile = "test.inp"; open(FH, "<$infile"); my @a = ; close(FH); my $alen = @a; my $i; my @b; open(FH, ">$outfile"); for($i = $alen - 101; $i < $alen; $i++) { @b = split("\t", $a[$i]); my $d = ""; for(my $u = 3; $u <= 6; $u++) { $d = $d . $b[$u - 1]; if($u < 6) { $d = $d . ","; } } print(FH "$d\n"); } close(FH);