FTN::Addr - Object-oriented module for creation and working with FTN addresses.
version 20160303
use FTN::Addr; my $a = FTN::Addr -> new( '1:23/45' ) or die "this is not a correct address"; my $b = FTN::Addr -> new( '1:23/45@fidonet' ) or die 'cannot create address'; print "Hey! They are the same!\n" if $a eq $b; # they actually are, because default domain is 'fidonet' $b -> set_domain( 'othernet' ); print "Hey! They are the same!\n" if $a eq $b; # no output as we changed domain $b = FTN::Addr -> new( '44.22', $a ) or die "cannot create address"; # takes the rest of information from optional $a $b = $a -> new( '44.22' ) or die "cannot create address"; # the same print $a -> f4, "\n"; # 1:23/45.0 print $a -> s4, "\n"; # 1:23/45 print $a -> f5, "\n"; # 1:23/45.0@fidonet print $a -> s5, "\n"; # 1:23/45@fidonet
FTN::Addr module is for creation and working with FTN addresses. Supports domains, different representations and comparison operators.
Can be called as class or object method:
my $t = FTN::Addr -> new( '1:23/45' ) or die 'something wrong!'; $t = $t -> new( '1:22/33.44@fidonet' ) or die 'something wrong!'; # advisable to use class call here instead: $t = FTN::Addr -> new( '1:22/33.44@fidonet' ) or die 'something wrong!';
Default domain is 'fidonet'. If point isn't specified, it's considered to be 0.
Address can be:
3d/4d 1:23/45 or 1:23/45.0 5d 1:23/45@fidonet or 1:23/45.0@fidonet fqfa fidonet#1:23/45.0 The Brake! FTN-compatible mailer for OS/2 style fidonet.1.23.45.0
If passed address misses any part except point and domain, the base is needed to get the missing information from (including domain). It can be optional second parameter (already created FTN::Addr object) in case of class method call or object itself in case of object method call.
my $an = FTN::Addr -> new( '99', $t ); # class call. address in $an is 1:22/99.0@fidonet $an = $t -> new( '99' ); # object call. the same resulting address.
Performs field validation.
In case of error returns undef in scalar context or empty list in list context.
$th = $an -> clone
Direct access to object fields. Checking is performed (dies on error). Setters return itself (for possible chaining).
$an -> set_domain( 'mynet' ); $an -> domain; $an -> domain( 'leftnet' );
$an -> set_zone( 2 ); $an -> zone; $an -> zone( 3 );
$an -> set_net( 456 ); $an -> net; $an -> net( 5020 );
$an -> set_node( 33 ); $an -> node; $an -> node( 60 );
$an -> set_point( 6 ); $an -> point; $an -> point( 0 );
print $an -> f4; # 1:22/99.0
print $an -> s4; # 1:22/99
print $an -> f5; # 1:22/99.0@fidonet
print $an -> s5; # 1:22/99@fidonet
print $an -> fqfa; # fidonet#1:22/99.0
print $an -> bs; # fidonet.1.22.99.0
Two addresses can be compared.
my $one = FTN::Addr -> new( '1:23/45.66@fidonet' ) or die "cannot create"; my $two = FTN::Addr -> new( '1:23/45.66@fidonet' ) or die "cannot create"; print "the same address!\n" if FTN::Addr -> equal( $one, $two ); # should print the message print "the same address!\n" if $one eq $two; # the same result print "but objects are different\n" if $one != $two; # should print the message
The same way (comparison rules) as 'eq' works 'cmp' operator.
Valery Kalesnik, <valkoles at gmail.com>
<valkoles at gmail.com>
Please report any bugs or feature requests to bug-ftn-addr at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FTN-Addr. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-ftn-addr at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc FTN::Addr
To install FTN::Addr, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FTN::Addr
CPAN shell
perl -MCPAN -e shell install FTN::Addr
For more information on module installation, please visit the detailed CPAN module installation guide.