NAME
PersonName::Format::NullObject - Null Value Chaining Object Class
SYNOPSIS
# In your code:
my $fmt = PersonName::Format->new( $faulty_args )->format( ... ) ||
die( PersonName::Format->error );
VERSION
v0.1.0
DESCRIPTION
Normally the call above would have triggered a perl error like Cannot call method name on an undefined value, but since "error" in PersonName::Format returns a PersonName::Format::NullObject object, the method format in our example is called without triggering an error, and returns the right value based on the expectation of the caller which will ultimately result in undef in scalar context or an empty list in list context.
PersonName::Format::NullObject uses AUTOLOAD to allow any method to work in chaining, but contains the original error within its object.
When the AUTOLOAD is called, it checks the call context and returns the current object in object (chaining context), or undef in scalar context or an empty list in list context.
METHODS
There is only 1 method. This module makes it possible to call it with any method to fake original data flow.
new
This takes no argument, and returns a new PersonName::Format::NullObject object.
CREDITS
Based on an original idea from Brian D. Foy discussed on StackOverflow and also on Perl Monks
AUTHOR
Jacques Deguest <jack@deguest.jp>
COPYRIGHT & LICENSE
Copyright(c) 2026 DEGUEST Pte. Ltd.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.