CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Method problem

 



fefecatz
New User

Mar 13, 2013, 2:05 PM

Post #1 of 2 (240 views)
Method problem Can't Post

Aww, today I decided to start learning perl, and made some useful programs.

However, this one fails every time I try to use variable in the methods, and i cannot figure out why.

I am doing networking, not programming, so sorry for the stupidity :D And thanks in advance for the help !

use Net::IRR;

my $host = 'whois.radb.net';
my $a=0;
my $i = Net::IRR->connect( host => $host )
or die "can't connect to $host\n";
my @as = $i->get_as_set("AS-57344");
print"@as";
my $count=@as;
for ( $i=0; $i<$count; $i++)

{

my @routes=$i->get_routes_by_origin("$as[$i]");
my $size=@routes;
for ( $i=0; $i<$size; $i++)
{

my $byte_size = length($routes[$i]);
if($byte_size>2)
{
$a = $a+10;
print"ip prefix-list seq $a permit $routes[$i] le 24 \n";

}
}
}


Code



wickedxter
User

Mar 13, 2013, 6:38 PM

Post #2 of 2 (231 views)
Re: [fefecatz] Method problem [In reply to] Can't Post

You were overridding the module Net::IRR in your loops.


Code
use Net::IRR;  

my $host = 'whois.radb.net';
my $a=0;
my $IRR = Net::IRR->connect( host => $host ) or die "can't connect to $host\n";
my @as = $IRR->get_as_set("AS-57344");

print"@as";

my $count= scalar @as;
for ( my $i=0; $i<$count; $i++) {

my @routes= $IRR->get_routes_by_origin($as[$i]);

my $size= scalar @routes;

for ( my $i=0; $i<$size; $i++) {
my $byte_size = length($routes[$i]);
if($byte_size>2) {
$a = $a+10;
print "ip prefix-list seq $a permit $routes[$i] le 24 \n";

}
}
}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives