LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2005, 09:29 AM   #1
makko
LQ Newbie
 
Registered: Apr 2004
Location: Earth
Distribution: Slackware 10, FreeBSD 4.10
Posts: 19

Rep: Reputation: 0
Dirty Perl


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
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--;
}
}
 
Old 09-16-2005, 10:59 AM   #2
jfryman
Member
 
Registered: Dec 2004
Location: Newport News, Virginia
Distribution: CentOS 4, FC4, Ubuntu Breezy/Dapper, Arch 0.7.1
Posts: 40

Rep: Reputation: 15
makko,

easy one! You are using () instead of {} with your hash constructor on lines 36 and 45. Change them around, you should be good!

Good luck!

-James
 
Old 09-17-2005, 10:46 AM   #3
makko
LQ Newbie
 
Registered: Apr 2004
Location: Earth
Distribution: Slackware 10, FreeBSD 4.10
Posts: 19

Original Poster
Rep: Reputation: 0
Actually, doode,

my $bitsc = undef

thats the problem. There's no semicollon.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
My College Did Me Dirty McNeesePimp General 19 03-26-2005 12:37 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
Two Quick and Dirty Ones! gsibble Linux - Newbie 9 08-14-2003 03:40 AM
quick and dirty! Smerk Debian 4 07-03-2003 08:33 PM
what qualifies as 'dirty' rickenbacherus Linux - General 6 03-10-2003 09:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration