See quotemeta and Iterator::Diamond
#!/usr/bin/perl -- use strict; use warnings; use Iterator::Files; my $search = quotemeta `uname -r`; my $input = Iterator::Files->new( files => [ '/etc/hosts' ], ); while( <$input> ){ s/$uname/$answer1/g; s/\Qdomainsuffix.net\E/$answer4/g; }
In reply to Re: Search and replace within a file
by Anonymous Monk
in thread Search and replace within a file
by muizelaar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |