#!perl -T ## no critic (TidyCode)
use strict;
use warnings;
use Try::Chain qw( $call_m );
our $VERSION = '0.001';
# create an object
sub new {
return bless {}, __PACKAGE__;
}
# and some methods
sub nothing {
return;
}
sub string {
return 'foo';
}
sub list {
return qw( bar baz );
}
my $counter = 0;
# string
() = print ++$counter, __PACKAGE__->new->$call_m('string'), "\n";
# list elements
() = print ++$counter, __PACKAGE__->new->$call_m('list'), "\n";
# nothing because of list context, otherwise undef
() = print ++$counter, __PACKAGE__->$call_m('nothing')->$call_m('string'), "\n";
# nothing because of list context, otherwise undef
() = print ++$counter, __PACKAGE__->new->$call_m('nothing')->$call_m('list'), "\n";
# $Id$
__END__
Output:
1foo
2barbaz
3
4