think i have to use tie::file.I went thru the perl doc ..but its not clear how to use it .could you give me a simple eg how to use it
for Tie::File, you have look at the file's lines as if they would be like "array elements", - by changing them you'd change the file. What did you try so far - what didn't work?
BTW, this problem looks rather simple, so you could employ your own file handling - sth. like this:
... my ($fnNew, $fnOld) = ('test.cfg', 'test.cfg.bak'); rename $fnNew, $fnOld or die "can't rename $fnNew, $!"; open my $fin, '<', $fnOld || die "$fnOld - $!"; open my $fout, '>', $fnNew || die "$fnNew - $!"; while( my $line = <$fin> ) { $line =~ s/(newyork\s+)1536000/${1}7878787878/; print $fout $line } close $fin; close $fout; ...
This would do basically the same as the 'one-liner' in another example already given.
Regards
mwa
In reply to Re^2: reg perl substitution
by mwah
in thread reg perl substitution
by pret_23_1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |