#reads in cvs file (comma-separated file) and returns only the xth column

if (@ARGV != 2){
  die "Usage: perl ExtractXthColumn.pl File x\n";
}

$File = $ARGV[0];
$x = $ARGV[1];

open (FILE,$File) or die "Couldn't open infile $File\n";
while(<FILE>){
  chomp;
  $_ =~ s/\r+//g;
  @Cols = split(/,/,$_);
  if (@Cols > $x){
    print $Cols[$x] . "\n";
  }
}
