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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.