Created
January 4, 2010 18:26
-
-
Save stevan/268717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Moose::Util::TypeConstraints; | |
use MooseX::Params::Validate; | |
subtype 'Filename' => as 'Str' => where { -x $_ }; | |
sub foo { | |
my ($name) = pos_validated_list( \@_, { isa => 'Filename' } ); | |
print "Houston, we have a filename: $name \n"; | |
} | |
my $perl = `which perl`; chomp $perl; | |
foo($perl); | |
foo('no_such_file'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stevan% perl ovid.pl | |
Houston, we have a filename: /usr/local/perls/bin/perl | |
Parameter #1 ("no_such_file") to main::foo did not pass | |
the 'checking type constraint for Filename' callback ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment