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

Without this mechanism, a failing constructor call in a method chain would set $obj to undef and the subsequent ->format() call would immediately die with Can't call method "format" on an undefined value. Because "error" in PersonName::Format returns a PersonName::Format::NullObject object instead of undef, the chain can continue gracefully: any method called on a NullObject returns the object itself in chaining context, undef in scalar context, or an empty list in list context, so the error is surfaced at the end of the chain rather than mid-expression.

PersonName::Format::NullObject uses AUTOLOAD to accept any method call. It retains the original exception within its object so it can be retrieved later.

METHODS

This module exposes a single public method. AUTOLOAD makes every other method call a no-op that propagates the null state through the chain.

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.