[techtalk] Oopsie!
Samuel Lavenz
johngalt at io.com
Thu Sep 28 13:24:03 EST 2000
There was a logic error on line 44 of the script I sent, here's a fix to
that.
Cheers!
Sam
--
-------------------------------------------------------------------------------
Sam Lavenz -- KC0BUH
johngalt at io.com
"I recognize no obligations toward men except one: to respect their
freedom and to take no part in a slave society"
-- Ayn Rand -- _The Fountainhead_ --
-------------- next part --------------
#!/usr/bin/perl
# This saves us some headaches...if there aren't two arguments, we
# print a usage message and exit.
unless ( scalar( @ARGV ) == 2 )
{
print "Usage: $0 [infile] [outfile]\n";
exit;
}
# We read from the file in the first argument
# We append to the file in the second
open INFILE, "<$ARGV[0]" or die "Could not open input file: $!";
open OUTFILE, ">>$ARGV[1]" or die "Could not open output file: $!";
# As long as we're getting input from our INFILE
while( <INFILE> )
{
next if /^$/; # Go on to the next line if this line is blank
chomp;
# This is where all the magic is done.
# We just run a pattern match on the string we've read in.
# The first set of parens captures anything up to the last
# period followed by anything, it stores it in $1
# The second (inner) set of parens captures the first character
# and stores it in $2.
#
# This effectively discards *anything* between the last . and the
# end of the string.
# mydomain.com => mydomain
# mydomain.yourdomain => mydomain
# so on
m/^((\w).*)\..*$/;
# $_ here is simply the string.
print OUTFILE "zone \"$_\" {\n",
"\ttype slave;\n",
"\tfile \"$2/db.$1\";\n\n",
"\tmasters {\n\t\t204.177.32.2;\n\t};\n",
"};\n\n";
}
close OUTFILE;
close INFILE;
More information about the Techtalk
mailing list