
phone4u
Novice
Aug 3, 2010, 5:42 AM
Post #7 of 11
(9571 views)
|
Re: [deepeshtronics] FOR LOOP HELP
[In reply to]
|
Can't Post
|
|
hi thanks a lot for your, it doesn't seem to work but I decided to paste the file lexo this way and try to use the for-loop to read the IPV6.txt , but each time the IP isn't available on the lexo list, it stops and give this error; "Can't call method "address" on an undefined value at b.pl line 3204, <IPV6> line 4428." Now, I hope you can help me with additional script that will ignore this error and continue with other IPs in the list till it reach the end. Here is what have done so far; #!/usr/bin/perl use Net::IPTrie; my $tr = Net::IPTrie->new(version=>6); # IPv6 $tr->add(address=>'2001:1200::/32', prefix=>'64', data=>'16531'); $tr->add(address=>'2001:1210::/32', prefix=>'64', data=>'2549'); $tr->add(address=>'2001:1218::/32', prefix=>'64', data=>'278'); $tr->add(address=>'2001:1228::/32', prefix=>'64', data=>'18592'); $tr->add(address=>'2001:1250::/32', prefix=>'64', data=>'28497'); $tr->add(address=>'2001:1258::/32', prefix=>'64', data=>'28499'); $tr->add(address=>'2001:1284::/32', prefix=>'64', data=>'14868'); $tr->add(address=>'2001:1291::/32', prefix=>'64', data=>'16735'); $tr->add(address=>'2001:1298::/32', prefix=>'64', data=>'28296'); $tr->add(address=>'2001:129c::/32', prefix=>'64', data=>'22356'); $tr->add(address=>'2001:12a4::/32', prefix=>'64', data=>'28346'); $tr->add(address=>'2001:12b0::/32', prefix=>'64', data=>'28618'); $tr->add(address=>'2001:12c0::/32', prefix=>'64', data=>'11706'); $tr->add(address=>'2001:12c4::/32', prefix=>'64', data=>'28262'); $tr->add(address=>'2001:12c8::/32', prefix=>'64', data=>'21911'); open IPV6, "<", "IPV6.txt" or die "Could not open file IPv6.txt in read mode: $!\n"; my @ipv6_content = <IPV6>; foreach my $line (@ipv6_content) { chomp $line; my $a = $tr->add(address=>"$line", data=>$data); # prefix defaults to 32 print "\$a is ". $a->address . " and parent of \$a is ". $a->parent->address ." and data of parents is: ". $a->parent->data. "\n"; } close IPV6;
|