sub index_split_join { return $_[0] unless index $_[0], 'STOCK' >= 0; # do a fast check to see if line needs to be looked at my @tokens = split /\|/, $_[0]; # split into columns $tokens[15] =~ s/STOCK/BOXXE/; # do replacement in col 16 return join('|',@tokens); # glue back together for final result }