The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

NetAddr::IP::LazyInit - NetAddr::IP objects with deferred validation SEE DESCRIPTION BEFORE USING

VERSION

0.3

SYNOPSIS

    use NetAddr::IP::LazyInit;

    my $ip = new NetAddr::IP::LazyInit( '10.10.10.5' );

DESCRIPTION

This module is designed to quickly create objects that may become NetAddr::IP objects. It accepts anything you pass to it without validation. Once a method is called that requires operating on the value, the full NetAddr::IP object is constructed.

You can see from the benchmarks that once you need to instantiate NetAddr::IP the speed becomes worse than if you had not used this module. What I mean is that this adds unneeded overhead if you intend to do IP operations on every object you create.

WARNING

Because validation is deferred, this module assumes you will only ever give it valid data. If you try to give it anything else, it will happily accept it and then die once it needs to inflate into a NetAddr::IP object.

CREDITS

This module was inspired by discussion with Jan Henning Thorsen, <jhthorsen at cpan.org>, and example code he provided. The namespace and part of the documentation/source is inspired by DateTime::LazyInit by Rick Measham, <rickm@cpan.org>

I didn't have to do much so I hate to take author credit, but I am providing the module, so complaints can go to me.

Robert Drake, <rdrake@cpan.org>

TODO

If we could actually load NetAddr::IP objects in the background while nothing is going on that would be neat. Or we could create shortcut methods when the user knows what type of input he has. new_from_ipv4('ip','mask'). We might be able to use Socket to build the raw materials and bless a new NetAddr::IP object without going through it's validation.

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Robert Drake

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.