Help for this page

Select Code to Download


  1. or download this
    use DateTime;
      subtype DateTime => as Object => where { $_->isa('DateTime') };
    
  2. or download this
    use DateTime;
      subtype 'DateTime' => as 'Object' => where { $_->isa('DateTime') };
    
  3. or download this
    use strict;
    use warnings;
    
    ...
    print "Is $thing new?    ".$obj->is_new($thing);
    $thing = to_NewType('House');
    print "Is $thing new?    ".$obj->is_new($thing);
    
  4. or download this
    package TmpTypes;
    
    use strict;
    ...
    coerce NewType,
      from Str,
      via { 'new_'.$_ };
    
  5. or download this
    subtype 'NewType',
      as 'Str',
      where {$_ =~ /^new_/};
    ...
    coerce 'NewType',
      from 'Str',
      via { 'new_'.$_ };
    
  6. or download this
    use strict;
    use warnings;
    use Moose::Util::TypeConstraints;
    ...
    print "Is $thing new?    ".$obj->is_new($thing);
    $thing = to_NewType('House');
    print "Is $thing new?    ".$obj->is_new($thing);
    
  7. or download this
    package TmpTypes;
    
    use strict;
    ...
    coerce 'NewType',
      from 'Str',
      via { 'new_'.$_ };