2 package Moose::Meta::Role;
8 use Scalar::Util 'blessed';
10 use Devel::GlobalDestruction 'in_global_destruction';
12 our $VERSION = '1.04';
13 $VERSION = eval $VERSION;
14 our $AUTHORITY = 'cpan:STEVAN';
16 use Moose::Meta::Class;
17 use Moose::Meta::Role::Attribute;
18 use Moose::Meta::Role::Method;
19 use Moose::Meta::Role::Method::Required;
20 use Moose::Meta::Role::Method::Conflicting;
21 use Moose::Util qw( ensure_all_roles );
23 use base 'Class::MOP::Module',
24 'Class::MOP::Mixin::HasAttributes',
25 'Class::MOP::Mixin::HasMethods';
27 ## ------------------------------------------------------------------
29 ## I normally don't do this, but I am doing
30 ## a whole bunch of meta-programmin in this
31 ## module, so it just makes sense. For a clearer
32 ## picture of what is going on in the next
33 ## several lines of code, look at the really
34 ## big comment at the end of this file (right
37 ## ------------------------------------------------------------------
39 my $META = __PACKAGE__->meta;
41 ## ------------------------------------------------------------------
45 # since roles are lazy, we hold all the attributes
46 # of the individual role in 'statis' until which
47 # time when it is applied to a class. This means
48 # keeping a lot of things in hash maps, so we are
49 # using a little of that meta-programmin' magic
50 # here an saving lots of extra typin. And since
51 # many of these attributes above require similar
52 # functionality to support them, so we again use
53 # the wonders of meta-programmin' to deliver a
54 # very compact solution to this normally verbose
60 name => 'excluded_roles_map',
61 attr_reader => 'get_excluded_roles_map' ,
63 add => 'add_excluded_roles',
64 get_keys => 'get_excluded_roles_list',
65 existence => 'excludes_role',
69 name => 'required_methods',
70 attr_reader => 'get_required_methods_map',
72 remove => 'remove_required_methods',
73 get_values => 'get_required_method_list',
74 existence => 'requires_method',
79 my $attr_reader = $action->{attr_reader};
80 my $methods = $action->{methods};
82 # create the attribute
83 $META->add_attribute($action->{name} => (
84 reader => $attr_reader,
88 # create some helper methods
89 $META->add_method($methods->{add} => sub {
90 my ($self, @values) = @_;
91 $self->$attr_reader->{$_} = undef foreach @values;
92 }) if exists $methods->{add};
94 $META->add_method($methods->{get_keys} => sub {
96 keys %{$self->$attr_reader};
97 }) if exists $methods->{get_keys};
99 $META->add_method($methods->{get_values} => sub {
101 values %{$self->$attr_reader};
102 }) if exists $methods->{get_values};
104 $META->add_method($methods->{get} => sub {
105 my ($self, $name) = @_;
106 $self->$attr_reader->{$name}
107 }) if exists $methods->{get};
109 $META->add_method($methods->{existence} => sub {
110 my ($self, $name) = @_;
111 exists $self->$attr_reader->{$name} ? 1 : 0;
112 }) if exists $methods->{existence};
114 $META->add_method($methods->{remove} => sub {
115 my ($self, @values) = @_;
116 delete $self->$attr_reader->{$_} foreach @values;
117 }) if exists $methods->{remove};
120 $META->add_attribute(
122 reader => 'method_metaclass',
123 default => 'Moose::Meta::Role::Method',
126 $META->add_attribute(
127 'required_method_metaclass',
128 reader => 'required_method_metaclass',
129 default => 'Moose::Meta::Role::Method::Required',
132 $META->add_attribute(
133 'conflicting_method_metaclass',
134 reader => 'conflicting_method_metaclass',
135 default => 'Moose::Meta::Role::Method::Conflicting',
138 $META->add_attribute(
139 'application_to_class_class',
140 reader => 'application_to_class_class',
141 default => 'Moose::Meta::Role::Application::ToClass',
144 $META->add_attribute(
145 'application_to_role_class',
146 reader => 'application_to_role_class',
147 default => 'Moose::Meta::Role::Application::ToRole',
150 $META->add_attribute(
151 'application_to_instance_class',
152 reader => 'application_to_instance_class',
153 default => 'Moose::Meta::Role::Application::ToInstance',
156 # More or less copied from Moose::Meta::Class
160 return Class::MOP::get_metaclass_by_name($pkg)
161 || $class->SUPER::initialize(
163 'attribute_metaclass' => 'Moose::Meta::Role::Attribute',
172 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
174 my %existing_classes;
176 %existing_classes = map { $_ => $meta->$_() } qw(
179 wrapped_method_metaclass
180 required_method_metaclass
181 conflicting_method_metaclass
182 application_to_class_class
183 application_to_role_class
184 application_to_instance_class
188 return $self->SUPER::reinitialize(
198 if (blessed $_[0] && ! $_[0]->isa('Moose::Meta::Role::Attribute') ) {
199 my $class = ref $_[0];
200 Moose->throw_error( "Cannot add a $class as an attribute to a role" );
202 elsif (!blessed($_[0]) && defined($_[0]) && $_[0] =~ /^\+(.*)/) {
203 Moose->throw_error( "has '+attr' is not supported in roles" );
206 return $self->SUPER::add_attribute(@_);
209 sub _attach_attribute {
210 my ( $self, $attribute ) = @_;
212 $attribute->attach_to_role($self);
215 sub add_required_methods {
220 if (!blessed($method)) {
221 $method = $self->required_method_metaclass->new(
225 $self->get_required_methods_map->{$method->name} = $method;
229 sub add_conflicting_method {
233 if (@_ == 1 && blessed($_[0])) {
237 $method = $self->conflicting_method_metaclass->new(@_);
240 $self->add_required_methods($method);
243 ## ------------------------------------------------------------------
247 # the before/around/after method modifiers are
248 # stored by name, but there can be many methods
249 # then associated with that name. So again we have
250 # lots of similar functionality, so we can do some
251 # meta-programmin' and save some time.
254 foreach my $modifier_type (qw[ before around after ]) {
256 my $attr_reader = "get_${modifier_type}_method_modifiers_map";
258 # create the attribute ...
259 $META->add_attribute("${modifier_type}_method_modifiers" => (
260 reader => $attr_reader,
261 default => sub { {} }
264 # and some helper methods ...
265 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
266 my ($self, $method_name) = @_;
267 #return () unless exists $self->$attr_reader->{$method_name};
268 my $mm = $self->$attr_reader->{$method_name};
272 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
273 my ($self, $method_name) = @_;
275 # for now we assume that if it exists,..
276 # it has at least one modifier in it
277 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
280 $META->add_method("add_${modifier_type}_method_modifier" => sub {
281 my ($self, $method_name, $method) = @_;
283 $self->$attr_reader->{$method_name} = []
284 unless exists $self->$attr_reader->{$method_name};
286 my $modifiers = $self->$attr_reader->{$method_name};
289 # check to see that we aren't adding the
290 # same code twice. We err in favor of the
291 # first on here, this may not be as expected
292 foreach my $modifier (@{$modifiers}) {
293 return if $modifier == $method;
296 push @{$modifiers} => $method;
301 ## ------------------------------------------------------------------
302 ## override method mofidiers
304 $META->add_attribute('override_method_modifiers' => (
305 reader => 'get_override_method_modifiers_map',
306 default => sub { {} }
310 # these are a little different because there
311 # can only be one per name, whereas the other
312 # method modifiers can have multiples.
315 sub add_override_method_modifier {
316 my ($self, $method_name, $method) = @_;
317 (!$self->has_method($method_name))
318 || Moose->throw_error("Cannot add an override of method '$method_name' " .
319 "because there is a local version of '$method_name'");
320 $self->get_override_method_modifiers_map->{$method_name} = $method;
323 sub has_override_method_modifier {
324 my ($self, $method_name) = @_;
326 # for now we assume that if it exists,..
327 # it has at least one modifier in it
328 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
331 sub get_override_method_modifier {
332 my ($self, $method_name) = @_;
333 $self->get_override_method_modifiers_map->{$method_name};
336 ## general list accessor ...
338 sub get_method_modifier_list {
339 my ($self, $modifier_type) = @_;
340 my $accessor = "get_${modifier_type}_method_modifiers_map";
341 keys %{$self->$accessor};
344 sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
345 sub update_package_cache_flag {
347 $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
352 ## ------------------------------------------------------------------
355 $META->add_attribute('roles' => (
356 reader => 'get_roles',
357 default => sub { [] }
361 my ($self, $role) = @_;
362 (blessed($role) && $role->isa('Moose::Meta::Role'))
363 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
364 push @{$self->get_roles} => $role;
365 $self->reset_package_cache_flag;
368 sub calculate_all_roles {
374 $_->calculate_all_roles
375 } @{ $self->get_roles });
379 my ($self, $role) = @_;
381 || Moose->throw_error("You must supply a role name to look for");
382 my $role_name = blessed $role ? $role->name : $role;
383 # if we are it,.. then return true
384 return 1 if $role_name eq $self->name;
385 # otherwise.. check our children
386 foreach my $role (@{$self->get_roles}) {
387 return 1 if $role->does_role($role_name);
392 sub find_method_by_name { (shift)->get_method(@_) }
395 Carp::cluck("The alias_method method is deprecated. Use add_method instead.\n");
399 $self->add_method(@_);
402 ## ------------------------------------------------------------------
404 ## ------------------------------------------------------------------
407 my ($self, $other, %args) = @_;
410 || Moose->throw_error("You must pass in an blessed instance");
412 my $application_class;
413 if ($other->isa('Moose::Meta::Role')) {
414 $application_class = $self->application_to_role_class;
416 elsif ($other->isa('Moose::Meta::Class')) {
417 $application_class = $self->application_to_class_class;
420 $application_class = $self->application_to_instance_class;
423 Class::MOP::load_class($application_class);
424 return $application_class->new(%args)->apply($self, $other, \%args);
427 sub composition_class_roles { }
430 my ($class, @role_specs) = @_;
432 require Moose::Meta::Role::Composite;
434 my (@roles, %role_params);
435 while (@role_specs) {
436 my ($role, $params) = @{ splice @role_specs, 0, 1 };
440 : Class::MOP::class_of($role);
442 my $actual_role = $requested_role->_role_for_combination($params);
443 push @roles => $actual_role;
445 next unless defined $params;
446 $role_params{$actual_role->name} = $params;
449 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
450 return $c->apply_params(\%role_params);
453 sub _role_for_combination {
454 my ($self, $params) = @_;
459 my ( $role, $package_name, %options ) = @_;
461 $options{package} = $package_name;
463 (ref $options{attributes} eq 'HASH')
464 || confess "You must pass a HASH ref of attributes"
465 if exists $options{attributes};
467 (ref $options{methods} eq 'HASH')
468 || confess "You must pass a HASH ref of methods"
469 if exists $options{methods};
471 my (%initialize_options) = %options;
472 delete @initialize_options{qw(
480 my $meta = $role->initialize( $package_name => %initialize_options );
482 $meta->_instantiate_module( $options{version}, $options{authority} );
485 $meta->add_method('meta' => sub {
486 $role->initialize(ref($_[0]) || $_[0]);
489 if (exists $options{attributes}) {
490 foreach my $attribute_name (keys %{$options{attributes}}) {
491 my $attr = $options{attributes}->{$attribute_name};
492 $meta->add_attribute(
493 $attribute_name => blessed $attr ? $attr : %{$attr} );
497 if (exists $options{methods}) {
498 foreach my $method_name (keys %{$options{methods}}) {
499 $meta->add_method($method_name, $options{methods}->{$method_name});
503 Class::MOP::weaken_metaclass($meta->name)
504 if $meta->is_anon_role;
512 for my $meta (Class::MOP::get_all_metaclass_instances) {
513 next if $meta->name eq $self->name;
514 next unless $meta->isa('Moose::Meta::Class')
515 || $meta->isa('Moose::Meta::Role');
516 push @consumers, $meta->name
517 if $meta->does_role($self->name);
522 # anonymous roles. most of it is copied straight out of Class::MOP::Class.
523 # an intrepid hacker might find great riches if he unifies this code with that
524 # code in Class::MOP::Module or Class::MOP::Package
527 # this should be sufficient, if you have a
528 # use case where it is not, write a test and
530 my $ANON_ROLE_SERIAL = 0;
533 # we need a sufficiently annoying prefix
534 # this should suffice for now, this is
535 # used in a couple of places below, so
536 # need to put it up here for now.
537 my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::';
541 no warnings 'uninitialized';
542 $self->name =~ /^$ANON_ROLE_PREFIX/;
545 sub create_anon_role {
546 my ($role, %options) = @_;
547 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
548 return $role->create($package_name, %options);
552 # this will only get called for
553 # anon-roles, all other calls
554 # are assumed to occur during
555 # global destruction and so don't
556 # really need to be handled explicitly
560 return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
562 no warnings 'uninitialized';
563 return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
565 # XXX: is this necessary for us? I don't understand what it's doing
568 # Moose does a weird thing where it replaces the metaclass for
569 # class when fixing metaclass incompatibility. In that case,
570 # we don't want to clean out the namespace now. We can detect
571 # that because Moose will explicitly update the singleton
572 # cache in Class::MOP.
573 #my $current_meta = Class::MOP::get_metaclass_by_name($self->name);
574 #return if $current_meta ne $self;
576 my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/);
578 foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) {
579 delete ${$ANON_ROLE_PREFIX . $serial_id}{$key};
581 delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'};
585 #####################################################################
587 ## This is Moose::Meta::Role as defined by Moose (plus the use of
588 ## MooseX::AttributeHelpers module). It is here as a reference to
589 ## make it easier to see what is happening above with all the meta
591 #####################################################################
594 # metaclass => 'Array',
595 # reader => 'get_roles',
596 # isa => 'ArrayRef[Moose::Meta::Role]',
597 # default => sub { [] },
599 # 'push' => 'add_role',
603 # has 'excluded_roles_map' => (
604 # metaclass => 'Hash',
605 # reader => 'get_excluded_roles_map',
606 # isa => 'HashRef[Str]',
608 # # Not exactly set, cause it sets multiple
609 # 'set' => 'add_excluded_roles',
610 # 'keys' => 'get_excluded_roles_list',
611 # 'exists' => 'excludes_role',
615 # has 'required_methods' => (
616 # metaclass => 'Hash',
617 # reader => 'get_required_methods_map',
618 # isa => 'HashRef[Moose::Meta::Role::Method::Required]',
620 # # not exactly set, or delete since it works for multiple
621 # 'set' => 'add_required_methods',
622 # 'delete' => 'remove_required_methods',
623 # 'keys' => 'get_required_method_list',
624 # 'exists' => 'requires_method',
628 # # the before, around and after modifiers are
629 # # HASH keyed by method-name, with ARRAY of
630 # # CODE refs to apply in that order
632 # has 'before_method_modifiers' => (
633 # metaclass => 'Hash',
634 # reader => 'get_before_method_modifiers_map',
635 # isa => 'HashRef[ArrayRef[CodeRef]]',
637 # 'keys' => 'get_before_method_modifiers',
638 # 'exists' => 'has_before_method_modifiers',
639 # # This actually makes sure there is an
640 # # ARRAY at the given key, and pushed onto
641 # # it. It also checks for duplicates as well
642 # # 'add' => 'add_before_method_modifier'
646 # has 'after_method_modifiers' => (
647 # metaclass => 'Hash',
648 # reader =>'get_after_method_modifiers_map',
649 # isa => 'HashRef[ArrayRef[CodeRef]]',
651 # 'keys' => 'get_after_method_modifiers',
652 # 'exists' => 'has_after_method_modifiers',
653 # # This actually makes sure there is an
654 # # ARRAY at the given key, and pushed onto
655 # # it. It also checks for duplicates as well
656 # # 'add' => 'add_after_method_modifier'
660 # has 'around_method_modifiers' => (
661 # metaclass => 'Hash',
662 # reader =>'get_around_method_modifiers_map',
663 # isa => 'HashRef[ArrayRef[CodeRef]]',
665 # 'keys' => 'get_around_method_modifiers',
666 # 'exists' => 'has_around_method_modifiers',
667 # # This actually makes sure there is an
668 # # ARRAY at the given key, and pushed onto
669 # # it. It also checks for duplicates as well
670 # # 'add' => 'add_around_method_modifier'
674 # # override is similar to the other modifiers
675 # # except that it is not an ARRAY of code refs
676 # # but instead just a single name->code mapping
678 # has 'override_method_modifiers' => (
679 # metaclass => 'Hash',
680 # reader =>'get_override_method_modifiers_map',
681 # isa => 'HashRef[CodeRef]',
683 # 'keys' => 'get_override_method_modifier',
684 # 'exists' => 'has_override_method_modifier',
685 # 'add' => 'add_override_method_modifier', # checks for local method ..
689 #####################################################################
700 Moose::Meta::Role - The Moose Role metaclass
704 This class is a subclass of L<Class::MOP::Module> that provides
705 additional Moose-specific functionality.
707 It's API looks a lot like L<Moose::Meta::Class>, but internally it
708 implements many things differently. This may change in the future.
712 C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>.
720 =item B<< Moose::Meta::Role->initialize($role_name) >>
722 This method creates a new role object with the provided name.
724 =item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
726 This method accepts a list of array references. Each array reference
727 should contain a role name or L<Moose::Meta::Role> object as its first element. The second element is
728 an optional hash reference. The hash reference can contain C<-excludes>
729 and C<-alias> keys to control how methods are composed from the role.
731 The return value is a new L<Moose::Meta::Role::Composite> that
732 represents the combined roles.
734 =item B<< $metarole->composition_class_roles >>
736 When combining multiple roles using C<combine>, this method is used to obtain a
737 list of role names to be applied to the L<Moose::Meta::Role::Composite>
738 instance returned by C<combine>. The default implementation returns an empty
739 list. Extensions that need to hook into role combination may wrap this method
740 to return additional role names.
742 =item B<< Moose::Meta::Role->create($name, %options) >>
744 This method is identical to the L<Moose::Meta::Class> C<create>
747 =item B<< Moose::Meta::Role->create_anon_role >>
749 This method is identical to the L<Moose::Meta::Class>
750 C<create_anon_class> method.
752 =item B<< $metarole->is_anon_role >>
754 Returns true if the role is an anonymous role.
756 =item B<< $metarole->consumers >>
758 Returns a list of names of classes and roles which consume this role.
762 =head2 Role application
766 =item B<< $metarole->apply( $thing, @options ) >>
768 This method applies a role to the given C<$thing>. That can be another
769 L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
770 (non-meta) object instance.
772 The options are passed directly to the constructor for the appropriate
773 L<Moose::Meta::Role::Application> subclass.
775 Note that this will apply the role even if the C<$thing> in question already
776 C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for
777 finding out if role application is necessary.
781 =head2 Roles and other roles
785 =item B<< $metarole->get_roles >>
787 This returns an array reference of roles which this role does. This
788 list may include duplicates.
790 =item B<< $metarole->calculate_all_roles >>
792 This returns a I<unique> list of all roles that this role does, and
793 all the roles that its roles do.
795 =item B<< $metarole->does_role($role) >>
797 Given a role I<name> or L<Moose::Meta::Role> object, returns true if this role
800 =item B<< $metarole->add_role($role) >>
802 Given a L<Moose::Meta::Role> object, this adds the role to the list of
803 roles that the role does.
805 =item B<< $metarole->get_excluded_roles_list >>
807 Returns a list of role names which this role excludes.
809 =item B<< $metarole->excludes_role($role_name) >>
811 Given a role I<name>, returns true if this role excludes the named
814 =item B<< $metarole->add_excluded_roles(@role_names) >>
816 Given one or more role names, adds those roles to the list of excluded
823 The methods for dealing with a role's methods are all identical in API
824 and behavior to the same methods in L<Class::MOP::Class>.
828 =item B<< $metarole->method_metaclass >>
830 Returns the method metaclass name for the role. This defaults to
831 L<Moose::Meta::Role::Method>.
833 =item B<< $metarole->get_method($name) >>
835 =item B<< $metarole->has_method($name) >>
837 =item B<< $metarole->add_method( $name, $body ) >>
839 =item B<< $metarole->get_method_list >>
841 =item B<< $metarole->find_method_by_name($name) >>
843 These methods are all identical to the methods of the same name in
844 L<Class::MOP::Package>
850 As with methods, the methods for dealing with a role's attribute are
851 all identical in API and behavior to the same methods in
852 L<Class::MOP::Class>.
854 However, attributes stored in this class are I<not> stored as
855 objects. Rather, the attribute definition is stored as a hash
856 reference. When a role is composed into a class, this hash reference
857 is passed directly to the metaclass's C<add_attribute> method.
859 This is quite likely to change in the future.
863 =item B<< $metarole->get_attribute($attribute_name) >>
865 =item B<< $metarole->has_attribute($attribute_name) >>
867 =item B<< $metarole->get_attribute_list >>
869 =item B<< $metarole->add_attribute($name, %options) >>
871 =item B<< $metarole->remove_attribute($attribute_name) >>
875 =head2 Required methods
879 =item B<< $metarole->get_required_method_list >>
881 Returns the list of methods required by the role.
883 =item B<< $metarole->requires_method($name) >>
885 Returns true if the role requires the named method.
887 =item B<< $metarole->add_required_methods(@names) >>
889 Adds the named methods to the role's list of required methods.
891 =item B<< $metarole->remove_required_methods(@names) >>
893 Removes the named methods from the role's list of required methods.
895 =item B<< $metarole->add_conflicting_method(%params) >>
897 Instantiate the parameters as a L<Moose::Meta::Role::Method::Conflicting>
898 object, then add it to the required method list.
902 =head2 Method modifiers
904 These methods act like their counterparts in L<Class::MOP::Class> and
905 L<Moose::Meta::Class>.
907 However, method modifiers are simply stored internally, and are not
908 applied until the role itself is applied to a class.
912 =item B<< $metarole->add_after_method_modifier($method_name, $method) >>
914 =item B<< $metarole->add_around_method_modifier($method_name, $method) >>
916 =item B<< $metarole->add_before_method_modifier($method_name, $method) >>
918 =item B<< $metarole->add_override_method_modifier($method_name, $method) >>
920 These methods all add an appropriate modifier to the internal list of
923 =item B<< $metarole->has_after_method_modifiers >>
925 =item B<< $metarole->has_around_method_modifiers >>
927 =item B<< $metarole->has_before_method_modifiers >>
929 =item B<< $metarole->has_override_method_modifier >>
931 Return true if the role has any modifiers of the given type.
933 =item B<< $metarole->get_after_method_modifiers($method_name) >>
935 =item B<< $metarole->get_around_method_modifiers($method_name) >>
937 =item B<< $metarole->get_before_method_modifiers($method_name) >>
939 Given a method name, returns a list of the appropriate modifiers for
942 =item B<< $metarole->get_override_method_modifier($method_name) >>
944 Given a method name, returns the override method modifier for that
945 method, if it has one.
953 =item B<< Moose::Meta::Role->meta >>
955 This will return a L<Class::MOP::Class> instance for this class.
961 See L<Moose/BUGS> for details on reporting bugs.
965 Stevan Little E<lt>stevan@iinteractive.comE<gt>
967 =head1 COPYRIGHT AND LICENSE
969 Copyright 2006-2010 by Infinity Interactive, Inc.
971 L<http://www.iinteractive.com>
973 This library is free software; you can redistribute it and/or modify
974 it under the same terms as Perl itself.