http://www.perlmonks.org?node_id=830028


in reply to Removing a chunk of HTML?

In your code you have just modified the string.So changes will not be affected in a file.
If you want to modify file contents,use the module File::Inplace module.

Example
use strict; use warnings; use File::Inplace; my $editor = new File::Inplace(file=>"filename",suffix=>".bak"); while ($_=$editor->next_line) { if(s/(.*)/"welcome"/) { $editor->replace_line($_); } } $editor->commit;

If we mention suffix then it will create the backup file with the given extension.