Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to Lookahead algorithm for IP subroutine by hok_si_la

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 18:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found