#!/usr/bin/perl -w use strict; open(my $columns,"<",$ARGV[0]) or die("could not open $ARGV[0]!"); open(my $file,"<",$ARGV[1]) or die("could not open the $ARGV[1]!"); my @columns = <$columns>; chomp(@columns); while(<$file>) { my @arr=split(/\s+/,$_); print @arr[-@columns], "\n"; }