Greetings monks
I need to come up with an algorithm to find $j sequential IP addresses within a single $vlan if. It is possible that there is not $j sequential address within the table. In that case $j addresses will be selected by the lowest value of difference between the highest octet4 and lowest octet4.
The code below selects $j IPs from $vlan according to their location within the table. I should also add that although there are many things that may need be changed regarding syntax, I really only have 30 mins to get this cranking.
Any ideas? Is there a quick way to do this?
Each $vlan contains about 250 or so address & $j <= 5
############################################################
sub getips
############################################################
{
my $j = shift;
my $vlan= shift;
my $name = "ips" . $j;
my ($sth, $dbh, %ips, $i, @iparray);
$dbh=DBI->connect('DBI:ODBC:Servers', { RaiseError => 1, AutoCommit =>
+ 0 });
$sth = $dbh->prepare( "SELECT IPs.* FROM IPs LEFT OUTER JOIN StaticIP
+s ON IPs.Octet1 = StaticIPs.octet1 AND IPs.Octet2 = StaticIPs.octet2
+AND IPs.Octet3 = StaticIPs.octet3 AND IPs.Octet4 = StaticIPs.octet4 W
+HERE (StaticIPs.octet1 IS NULL) AND (IPs.VLAN = '$vlan')" );
$sth->execute;
$sth->bind_columns( \( @ips{ @{$sth->{NAME_lc} } } )); #----Saves spe
+ed by binding columns to their values. See netTools_help.doc.
$sth->{'ChopBlanks'} =1; #----Removes extra spaces from fixed char
+fields. See netTools_help.doc.
$i=0;
while ($sth->fetch) {
if ($ips{'octet1'}) {
$iparray[$i]=join(".", "$ips{'octet1'}", "$ips{'octet2'}", "$ips{'
+octet3'}", "$ips{'octet4'}");
}
++$i;
}
$j--;
print scrolling_list(-class=>'df', -name=>'$name', -values=>[@iparray]
+, -size=>'1', -default=>$iparray[$j]);
$sth->finish();
$dbh->disconnect(); #----Needed to free up system resources.
}
Thanks in advance,
hok_si_la
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.