troubleshooting Question

use an input file to replace

Avatar of richsark
richsarkFlag for United States of America asked on
PerlShell Scripting
14 Comments1 Solution293 ViewsLast Modified:
Hello Folks,

I have this perl script

use File::Find;
open F,shift or die $!;
my %ip=map/(\S+)\s+(\S+)/,<F>;
close F;
find sub{
  if( -f ){
     local @ARGV=($_);
     local $^I="";
     while( <> ){
           !/#/ && s/(\w+)domain-name-servers/$ip{$1}/g;

Its not working and need help to make it work.

I have an input file called "rich-input.txt"

In the fie I have lines that look like so

In my PWD

I have many folders like R1, R2, W2 etc...

What I am trying to do is have this script look in every directory find the line that has

option domain-name-servers,

and change to an IP like so:

option domain-name-servers,

Also skipping any # that may exist

The script runs somewhat but it changes stuff I dont want i.e option domain-name

Plus is screws up my input file with all IP's

I run it from (( using cygwin):


or in windows:


using rich-input.txt *

Thanks for your help in advanced
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros