NAME
FTN::Addr - working with FTN addresses
VERSION
version 20250717
SYNOPSIS
use FTN::Addr ();
my $a = FTN::Addr -> new( '1:23/45' )
or die "this is not a correct address";
my ( $b, $error ) = FTN::Addr -> new( '1:23/45@fidonet' );
if ( $error
) { # process the error (notify, log, die, ...)
die 'cannot create address because: ' . $error;
}
print "Hey! They are the same!\n"
if $a eq $b; # they actually are, because default domain is 'fidonet'
if ( my $error = $b -> set_domain( 'othernet' )
) {
# process the error (notify, log, die, ...)
}
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 missing information from optional $a
# or the same if you want to know what was the reason of failure (if there was a failure)
( $b, $error ) = FTN::Addr -> new( '44.22', $a );
if ( $error
) {
# process the error (notify, log, die, ...)
}
# can also be called as object method
( $b, $error ) = $a -> new( '44.22' );
if ( $error
) {
# process the error (notify, log, die, ...)
}
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
DESCRIPTION
FTN::Addr is a module for working with FTN addresses. Supports domains, different representations and comparison operators.
OBJECT CREATION
new
Can be called as class or object method. Performs fields validation.
In scalar context an object is returned. Or undef in case of an error.
In list context the pair ( $object, $error ) is returned. If $error is false - $object is good to be used. In case of error $object isn't usable and $error holds information about the failure.
my $t = FTN::Addr -> new( '1:23/45' )
or die 'something wrong!';
my $k = $t -> new( '22/33.44@fidonet' ) # the missing information will be taken from the $t object
or die 'something wrong!';
my ( $l, $error ) = FTN::Addr -> new( '1:22/33.44@fidonet' );
if ( $error
) { # do something about the error
die 'cannot created an address because: ' . $error;
}
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 an optional second parameter (already created FTN::Addr object) in case of class method call or an object itself in case of object method call.
my $an = FTN::Addr -> new( '99', $k ); # class call. address in $an is 1:22/99.0@fidonet
$an = $k -> new( '99' ); # object call. the same resulting address.
or use list context if you want to know the details of validation failure:
( $an, $error ) = $k -> new( '99' );
clone
my $clone_addr = $an -> clone;
FIELD ACCESS
Direct access to object fields.
domain
Returns current domain.
my $domain = $an -> domain;
set_domain
Sets new domain to the current address. Validation is performed. Returned true value is a string describing failure in validation. False value means new value is valid.
if ( my $error = $an -> set_domain( 'mynet' )
) {
# deal with error here (notify, log, request valid, ...)
}
zone
Returns current zone value.
my $zone = $an -> zone;
set_zone
Sets new zone to the current address. Validation is performed. Returned true value is a string describing failure in validation. False value means new value is valid.
if ( my $error = $an -> set_zone( 2 )
) {
# deal with error here (notify, log, request valid, ...)
}
net
Returns current net value.
my $net = $an -> net;
set_net
Sets new net to the current address. Validation is performed. Returned true value is a string describing failure in validation. False value means new value is valid.
if ( my $error = $an -> set_net( 456 )
) {
# deal with error here (notify, log, request valid, ...)
}
node
Returns current node value.
my $node = $an -> node;
set_node
Sets new node to the current address. Validation is performed. Returned true value is a string describing failure in validation. False value means new value is valid.
if ( my $error = $an -> set_node( 33 )
) {
# deal with error here (notify, log, request valid, ...)
}
point
my $point = $an -> point;
set_point
Sets new point to the current address. Validation is performed. Returned true value is a string describing failure in validation. False value means new value is valid.
if ( my $error = $an -> set_point( 6 )
) {
# deal with error here (notify, log, request valid, ...)
}
if ( my $error = $an -> set_point( 0 )
) {
# deal with error here (notify, log, request valid, ...)
}
REPRESENTATION
f4
Full 4d address (without domain):
print $an -> f4; # 2:456/33.0
s4
Short form (if possible) of 4d address:
print $an -> s4; # 2:456/33
f5
Full 5d address (with domain):
print $an -> f5; # 2:456/33.0@mynet
s5
Short form (if possible - only for nodes) of 5d address:
print $an -> s5; # 2:456/33@mynet
fqfa
Full qualified FTN address:
print $an -> fqfa; # mynet#2:456/33.0
bs
The Brake! FTN-compatible mailer for OS/2 style representation:
print $an -> bs; # mynet.2.456.33.0
COMPARISON
equal, eq, cmp
Two addresses can be compared.
( my $one, $error ) = FTN::Addr -> new( '1:23/45.66@fidonet' );
die "cannot create: " . $error
if $error;
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.
AUTHOR
Valery Kalesnik, <valkoles at gmail.com>
BUGS
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.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc FTN::Addr