in reply to Replacing text inside lots of files
# expecting that $file has file name. open (INF,"$file") or die "Unable to open \'$file\': $!"; open (OUTF,".temp_file") or die "Unable to create temp file: $!"; my $line=readline(INF); chomp($line); # if windows remember to $line=~s/\r$//o; # now change the last 10 characters from first line $line=~s/.{10}$/$file/; print "$line\n"; # this reads every line in file and prints it as is while (<INF>) { print OUTF "$_"; } rename (".temp_file","$file");
# remove all the character after last dot $line=~s/\.\w+$//o;
|
|---|