Problems? Is your data what you think it is? | |
PerlMonks |
Search and replace within a fileby muizelaar (Sexton) |
on May 08, 2012 at 10:17 UTC ( [id://969404]=perlquestion: print w/replies, xml ) | Need Help?? |
muizelaar has asked for the wisdom of the Perl Monks concerning the following question: Got a problem which I’m not sure why it’s happening and wondered if you could help? I have written the code below to search the /etc/hosts file to search and replace all entries which have the host name and domain name suffix with what the user has input when the whole script has been run. For example I want to change the below within the /etc/hosts file servername.domainsuffix.net servername to newname.domainsuffix.org newname My problem is that where I have placed the $uname (which is the uname –r output from the system) it is not being replaced. However where I have the domain name suffix part which is an actual name it does replace this and $uname replaces the server name after the FQN if you get what I mean. Apologies if this is not clear it sounds ok in my head :-) From the example above I get the following Servername.domainsuffix.org newname
Back to
Seekers of Perl Wisdom
|
|