use strict; my $data_file = $ARGV[0]; #input file my $old_delim = $ARGV[1]; # old delimeter my $output_file = $ARGV[2]; # out put file my $new_delim = $ARGV[3]; # new delimeter my $count =0; print "\n$0 Started.....\n\n"; print " Input file name: $data_file\n"; print " File delimiter $old_delim\n"; print " Output file name: $output_file\n"; print " File delimiter $new_delim\n"; open(INFILE, "$data_file") || die "INPUT ERROR: $!\n"; #open file or kill the script and return the error die "INPUT ERROR: input file is empty\n" if( -s $data_file < 1); # if the file is empty, kill the script and print out an error message open(OUTFILE, ">$output_file") || die "OUTPUT ERROR: $!\n"; while(){ $_ =~ s/,\s*(\".*?), (.*?)\"/$1-=O=-$2/g; $_ =~ tr/\\\"//d; my @words = split($old_delim,$_); my $newline = join($new_delim,@words); $newline =~ s/-=O=-/,/g; print OUTFILE $newline; $count++; } print "line count: $count\n"; print ("\n\nCompleted.\n\n");