ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:
My text file contains this type of lines. In first you can identify Date. I want to replace it with "18 May 2015" in the same file like
18 May 2015 <114319747011000001>,20150518230002,,917696706652,01,,52727,rch,,admin,,,,01,21314,,,,bulkpull2I am coming by step to step. When i am here it gives an error.
Error: Can't modify constant item in scalar assignment at date.pl line 1, near "10," Execution of date.pl aborted due to compilation errors.open(DATA,"<Pull-2015-5-18-23.txt"); my $find = "20150518"; my $replace = "18 May 2015"; while(my $line = <DATA>) { $line =~ s/$find/$replace/g; print $line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using s///g;
by GrandFather (Saint) on Aug 06, 2015 at 11:36 UTC | |
by ravi45722 (Pilgrim) on Aug 06, 2015 at 11:43 UTC | |
|
Re: using s///g;
by taiko (Sexton) on Aug 06, 2015 at 11:38 UTC | |
by ravi45722 (Pilgrim) on Aug 06, 2015 at 11:51 UTC | |
by Laurent_R (Canon) on Aug 06, 2015 at 12:46 UTC | |
by taiko (Sexton) on Aug 06, 2015 at 12:48 UTC | |
|
Re: using s///g;
by GotToBTru (Prior) on Aug 06, 2015 at 12:39 UTC | |
|
Re: using s///g;
by ww (Archbishop) on Aug 06, 2015 at 12:02 UTC | |
|
Re: using s///g;
by SimonPratt (Friar) on Aug 06, 2015 at 11:52 UTC | |
by GrandFather (Saint) on Aug 06, 2015 at 21:02 UTC |