Jason Duan wrote: > Hi, Hello,
> I am using the Net::Netmask module to handle some IP prefix problems. > I have a question about its usage. I want to store a block in two > tables, and I may delete the block from one of the tables at some later > time, it appears that the block is deleted from both tables. See the > following code. perldoc Net::Netmask [snip] ->storeNetblock([$t]) Adds the current block to an table of network blocks. The table can be used to query which network block a given IP address is in. The optional argument allows there to be more than one table. By default, an internal table is used. If more than one table is needed, then supply a reference to a HASH to store the data in. ->deleteNetblock([$t]) Deletes the current block from a table of network blocks. The optional argument allows there to be more than one table. By default, an internal table is used. If more than one table is needed, then supply a reference to a HASH to store the data in. > #!/usr/bin/perl -w > use strict; > use Net::Netmask; > > my $t1; > my $t2; > > my $ip = "x.y.1.1"; > my $prefix = "x.y.0.0/16"; > > my $block = new Net::Netmask($prefix); Here $block is an object that contains the current Netblock "x.y.0.0/16". > $block->storeNetblock($t1); > $block->storeNetblock($t2); Because both $t1 and $t2 are undefined you are adding nothing to the current Netblock. > $block->deleteNetblock($t1); Because $t1 is undefined you are deleting the current Netblock "x.y.0.0/16". > my $newblock = findNetblock($ip, $t2); > > if ($newblock) { > my $ippref = $newblock->desc(); > print "$ippref\n"; > } > > It turns out that $newblock is undefined. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>