Re: Process a single field file
At 05:49 PM 5/9/01 +1000, you wrote: >Hi very new to perl... am getting some books asap. Looks like Lincoln Stein's "Network Programming with Perl" would be apposite... >I am writing a script to create named.conf records from a single field >text file > >eg, domain.fle >domain1.com >domain2.net >domain3.org > >and then create a named.conf entry from; > >$namedconf="/etc/namedb/named.conf" ; >$namednow="/etc/namedb/named.conf.$now" ; >$namedtmp="/etc/namedb/named.conf.tmp" ; > >unless (-e $namedconf) { die "$namedconf does not exist!" } You'll probably want to put a \n in that die. >open (NAMEDNOW, "> $namednow") || die "Cannot open $namedtmp for >writing\n\n" ; Er, the file in the die is not the same as the one in the open... >open (NAMED, $namedconf) || die "Cannot open $namedconf for reading\n\n" ; >Lock::wlock(NAMED); > >while () { >if ((/nextprimary/) && ($domaintype eq "primary")) { >print NAMEDNOW < >zone "$domainname" { > type master; > allow-query { any; } ; > file "zones/$domainname"; >}; > >ENUF > >Newbie please be gentle... You're asking for a critique? The above code is incomplete, so that's hard to do. I don't see a -w/use warnings or use strict in there, so those would be essential to add. Also, the script at least as it appeared to me didn't have indentation inside blocks; pretty code layout is far more important than most people think. Otherwise, style and usage are fine. I'm not familiar with the Lock module you appear to be using, and I don't see it on CPAN. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com
Re: Process a single field file
Can you sepcify what your problem is, exactly. At a first glance your code looks fine... cr On Wed, 09 May 2001 17:49:16 +1000, Clayton Winter said: > Hi very new to perl... am getting some books asap. > > I am writing a script to create named.conf records from a single field > text file > > eg, domain.fle > domain1.com > domain2.net > domain3.org > > and then create a named.conf entry from; > > $namedconf="/etc/namedb/named.conf" ; > $namednow="/etc/namedb/named.conf.$now" ; > $namedtmp="/etc/namedb/named.conf.tmp" ; > > unless (-e $namedconf) { die "$namedconf does not exist!" } > > open (NAMEDNOW, "> $namednow") || die "Cannot open $namedtmp for > writing\n\n" ; > open (NAMED, $namedconf) || die "Cannot open $namedconf for reading\n\n" ; > Lock::wlock(NAMED); > > while () { > if ((/nextprimary/) && ($domaintype eq "primary")) { > print NAMEDNOW < > zone "$domainname" { > type master; > allow-query { any; } ; > file "zones/$domainname"; > }; > > ENUF > > Newbie please be gentle... > >
Process a single field file
Hi very new to perl... am getting some books asap. I am writing a script to create named.conf records from a single field text file eg, domain.fle domain1.com domain2.net domain3.org and then create a named.conf entry from; $namedconf="/etc/namedb/named.conf" ; $namednow="/etc/namedb/named.conf.$now" ; $namedtmp="/etc/namedb/named.conf.tmp" ; unless (-e $namedconf) { die "$namedconf does not exist!" } open (NAMEDNOW, "> $namednow") || die "Cannot open $namedtmp for writing\n\n" ; open (NAMED, $namedconf) || die "Cannot open $namedconf for reading\n\n" ; Lock::wlock(NAMED); while () { if ((/nextprimary/) && ($domaintype eq "primary")) { print NAMEDNOW <