#!/usr/bin/perl use strict; use warnings; use Getopt::Long; GetOptions( '-F=s' => \my $delim, '-i=n' => \my $index, ); $delim = " " unless defined $delim; $index = 1 unless defined $index; @ARGV = ($ARGV[-1]); while( <> ){ chomp; print +(split /\Q$delim\E/,$_ )[$index-1],"\n"; }