bimleshsharma has asked for the wisdom of the Perl Monks concerning the following question:
I have csv file and i want to modify some field's value. I tried by creating new csv with modified value and then renamed with original one but i want to open that file in read/write mode and do simultaneously(no rename). Here is what i tried but not successful. Thanks in advance.
sub modifying_csv { my $file=shift; open FH,"+<$file"; while(<FH>) { my $line= $_; if($line =~ /43950635/) { $line =~ s/(.*)(43950635)(.*)/"$1$2BIM$3"/; $line =~ s/\"//g; #print "$line"; print FH "$line"; } } close FH;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Modify csv file.
by Tux (Canon) on Nov 05, 2012 at 12:10 UTC | |
|
Re: Modify csv file.
by BillKSmith (Monsignor) on Nov 05, 2012 at 13:27 UTC | |
by clueless newbie (Curate) on Nov 05, 2012 at 15:23 UTC | |
|
Re: Modify csv file.
by Anonymous Monk on Nov 06, 2012 at 01:14 UTC | |
|
Re: Modify csv file.
by marinersk (Priest) on Nov 06, 2012 at 07:16 UTC |