One of the features of Type::Tiny that differentiates it from Moose's built-in type constraint system is that it allows stand-alone coercions which can then be mixed with type constraints as required. So if you had a
Split coercion which split a multi-line string into an arrayref of lines, you could do something like this:
use MyApp::Types qw( ArrayRef Split );
has lines => (
is => 'ro',
isa => ArrayRef + Split,
coerce => 1,
This is one of several features designed to encourage people to combine coercions with type…
The smartmatch operator (
~~) introduced in Perl 5.10 (and borrowed from Perl 6) has been the subject of much criticism. Its behaviour changes based on the types of its arguments (arrays vs hashes vs numbers vs strings vs ...). perlop lists over twenty different behaviours based on different combinations of arguments. Although the operator normally does what you want, what people would want from certain combinations (
%hash ~~ @arr anybody?) is nor always clear.
(Aside: in Perl 6 which has a stronger type system, the behaviour of smartmatch is more predictable.)
For this reason, it has been proposed that the smartmatch operator be simplified, or perhaps even removed in a future version of Perl 5. To this end, Perl 5.18 has introduced some warnings about its experimental nature.