M
makko
I wrote this perl script to generate reverse dns zonefiles but this
error keeps popping up. Line 45 is the end of the binary table. can
anyone detect what the problem is?;
"Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45."
Here's the code:
##!/usr/bin/perl -T
# Copyright (C) 2005, Timothy Makobu
use warnings;
use strict;
# This program generates reverse DNS zonefiles for a given subnet.
unless($#ARGV+1 == 1)
{
print "This program generates reverse DNS zonefiles for a given
subnet.\n";
print "Usage inthezone.pl [ipblock]\n";
print "Example: inthezone2.pl 10.0.0.0/10\n";
exit 1;
}
my $subnet = $ARGV[0];
unless($subnet =~
m#^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})$#)
{
print "Invalid IP block\n";
exit 1;
}
# Here we go
my $slash = $5;
if($slash < 9)
{
print "Invalid IP block. Bigger than a class A block\n";
exit 1;
}
elsif($slash > 32)
{
print "There's no such thing on IPV4 doode, :-D\n";
exit 1;
}
my $bits = 32 - $slash;
my $decbits = 0;
my $reverse_dns = undef;
my $dbits = undef;
my $bitsc = undef
my %binarytable = (
1=>1,
2=>2,
3=>4,
4=>8,
5=>16,
6=>32,
7=>64,
8=>128);
while($bits)
{
$decbits += $binarytable{$bits};
$bits--;
}
if($bits <= 8)
{
open ZONE,">$1.$2.$3.db" or die $!;
select ZONE;
my $dbits = $decbits;
while($dbits)
{
$reverse_dns = "$dbits.$3.$2.$1.IN-ADDR.ARPA\n";
print $reverse_dns;
$dbits--;
}
close ZONE;
}
elsif($bits <= 16)
{
my $bitsc = $decbits - 255;
while($bitsc)
{
open ZONE,">$1.$2.$bitsc.db" or die $!;
select ZONE;
$dbits = 255;
while($dbits)
{
$reverse_dns = "$dbits.$bitsc.$2.$1.IN-ADDR.ARPA\n";
print $reverse_dns;
$dbits--;
}
close ZONE;
$bitsc--;
}
}
elsif($bits <=24)
{
$bitsc = $decbits - 255;
while($bitsc)
{
my $bitscc = 255;
while($bitscc)
{
open ZONE,">$1.$bitsc.$bitscc.db" or die $!;
select ZONE;
$dbits = 255;
while($dbits)
{
$reverse_dns = "$dbits.$3.$2.$1.IN-ADDR.ARPA\n";
print $reverse_dns;
$dbits--;
}
close ZONE;
$bitscc--;
}
$bitsc--;
}
}
error keeps popping up. Line 45 is the end of the binary table. can
anyone detect what the problem is?;
"Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45.
Useless use of a constant in void context at inthezone2.pl line 45."
Here's the code:
##!/usr/bin/perl -T
# Copyright (C) 2005, Timothy Makobu
use warnings;
use strict;
# This program generates reverse DNS zonefiles for a given subnet.
unless($#ARGV+1 == 1)
{
print "This program generates reverse DNS zonefiles for a given
subnet.\n";
print "Usage inthezone.pl [ipblock]\n";
print "Example: inthezone2.pl 10.0.0.0/10\n";
exit 1;
}
my $subnet = $ARGV[0];
unless($subnet =~
m#^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})$#)
{
print "Invalid IP block\n";
exit 1;
}
# Here we go
my $slash = $5;
if($slash < 9)
{
print "Invalid IP block. Bigger than a class A block\n";
exit 1;
}
elsif($slash > 32)
{
print "There's no such thing on IPV4 doode, :-D\n";
exit 1;
}
my $bits = 32 - $slash;
my $decbits = 0;
my $reverse_dns = undef;
my $dbits = undef;
my $bitsc = undef
my %binarytable = (
1=>1,
2=>2,
3=>4,
4=>8,
5=>16,
6=>32,
7=>64,
8=>128);
while($bits)
{
$decbits += $binarytable{$bits};
$bits--;
}
if($bits <= 8)
{
open ZONE,">$1.$2.$3.db" or die $!;
select ZONE;
my $dbits = $decbits;
while($dbits)
{
$reverse_dns = "$dbits.$3.$2.$1.IN-ADDR.ARPA\n";
print $reverse_dns;
$dbits--;
}
close ZONE;
}
elsif($bits <= 16)
{
my $bitsc = $decbits - 255;
while($bitsc)
{
open ZONE,">$1.$2.$bitsc.db" or die $!;
select ZONE;
$dbits = 255;
while($dbits)
{
$reverse_dns = "$dbits.$bitsc.$2.$1.IN-ADDR.ARPA\n";
print $reverse_dns;
$dbits--;
}
close ZONE;
$bitsc--;
}
}
elsif($bits <=24)
{
$bitsc = $decbits - 255;
while($bitsc)
{
my $bitscc = 255;
while($bitscc)
{
open ZONE,">$1.$bitsc.$bitscc.db" or die $!;
select ZONE;
$dbits = 255;
while($dbits)
{
$reverse_dns = "$dbits.$3.$2.$1.IN-ADDR.ARPA\n";
print $reverse_dns;
$dbits--;
}
close ZONE;
$bitscc--;
}
$bitsc--;
}
}