#!/bin/perl -w use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new(); # creates object my $in_file = 'C:\Documents and Settings\x0199665\My Documents\temporary.tl'; # input file open my $in_fh, '<', $in_file or die "could not open $in_file: $!\n"; # assigns the file handler to input file as in_fh my @rows = (); # keeps the count of rows in txt input file while( my $line = <$in_fh> ){ # copies the line from our input chomp $line; push @rows, [ split m{ ,}msx, $line ]; # splits the contents of $line seperated by comma and pushes it in array } close $in_fh or die "could not close $in_file: $!\n"; $csv->eol( "\n" ); # after each line it gives a new line command print " Please enter the name of your csv file in which you will make modifications "; print "\n"; my $out_file = <>; chomp $out_file; open my $out_fh ,">", $out_file or die "could not open $out_file: $!\n"; for my $row ( @rows ){ $csv->print( $out_fh, $row ) or die "could not print to $out_file: $!\n"; # prints out the csv format } close $out_fh or die "could not close $out_file: $!\n"; my $rm_file = "temporary.tl"; unlink($rm_file) ; # this will remove the temporary file exit;