pass in array or list of files

J

joe shaboo

Hi again,

I'm still working on a dns script. Last time I received some help and
everything works as it should. Basically, it takes the named.conf file
and comments out the next 5 lines of a domain that is given. THis
works great if the domain is hardcoded into the script.

What I'm trying to do is run through a file, and comment out names in
my named.conf file that are no longer hosted.

The script basically has

@ARGV = ("named.conf")

while (<>) {
if (/\b<a new domain feed from a list>/) {
$commenting = 1;
}
print "//" if $commenting;
print;
$commenting = 0 if /^\s*}/;
}
exit;

How can I pass in a new variable from file1, in some kind of for loop?

So, it will individually go through file1, which contains, test.com,
test.net, test.org, test.ws, and comment them out of my named.conf.

Also, alternatively, it would be nice to pass the name of the domain
at the command line. Simple, right...

Thanks,

Joe
 
B

Brian McCauley

I'm still working on a dns script. Last time I received some help and
everything works as it should. Basically, it takes the named.conf file
and comments out the next 5 lines of a domain that is given. THis
works great if the domain is hardcoded into the script.

What I'm trying to do is run through a file, and comment out names in
my named.conf file that are no longer hosted.

The script basically has

@ARGV = ("named.conf")

while (<>) {
if (/\b<a new domain feed from a list>/) {
$commenting = 1;
}
print "//" if $commenting;
print;
$commenting = 0 if /^\s*}/;
}
exit;

How can I pass in a new variable from file1, in some kind of for loop?

You are asking how to read file line linewise? Why, you open it with
So, it will individually go through file1, which contains, test.com,
test.net, test.org, test.ws, and comment them out of my named.conf.

Probably simpler to slurp the whole file into an array (see FAQ) then
iterate over that array within the loop that iterates over the lines
of named.conf.
Also, alternatively, it would be nice to pass the name of the domain
at the command line. Simple, right...

Yes, command line arguments are in @ARGV (so long as you don't change it).

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top