Sha256: 6fb1523283a3c0883dc34af87e4679a72f60d77db03a636a1471663b8059774d

Contents?: true

Size: 1.87 KB

Versions: 105

Compression:

Stored size: 1.87 KB

Contents

package Attribute::Alias;

use warnings;
use strict;
use Attribute::Handlers;

our $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)/g;

sub UNIVERSAL::Alias : ATTR {
	my ($pkg, $symbol, $data) = @_[0,1,4];
	no strict 'refs';
	*{"$pkg\::$_"} = $symbol for ref $data eq 'ARRAY' ? @$data : $data;
}

"Rosebud"; # for MARCEL's sake, not 1 -- dankogai

__END__

=head1 NAME

Attribute::Alias - An Alias attribute

=head1 SYNOPSIS

  use Attribute::Alias;

  sub color : Alias(colour) { return 'red' }

=head1 DESCRIPTION

If you need a variable or subroutine to be known by another name,
use this attribute. Internally, the attribute's handler assigns
typeglobs to each other. As such, the C<Alias> attribute provides
a layer of abstraction. If the underlying mechanism changes in a
future version of Perl (say, one that might not have the concept
of typeglobs anymore :), a new version of this module will take
care of that, but your C<Alias> declarations are going to stay the
same.

Note that assigning typeglobs means that you can't specify a synonym
for one element of the glob and use the same synonym for a different
target name in a different slot. I.e.,

  sub color :Alias(colour) { ... }
  my $farbe :Alias(colour);

doesn't make sense, since the sub declaration aliases the whole
C<colour> glob to C<color>, but then the scalar declaration aliases
the whole C<colour> glob to C<farbe>, so the first alias is lost.

=head1 BUGS

None known so far. If you find any bugs or oddities, please do inform the
author.

=head1 AUTHOR

Marcel Grunauer, <marcel@codewerk.com>

Dan Kogai, C<< <dankogai+cpan at gmail.com> >>

=head1 COPYRIGHT

Copyright 2001 Marcel Grunauer.  All rights reserved.

Copyright 2006 Dan Kogai.  All rights reserved.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 SEE ALSO

perl(1), L<Attribute::Handlers>

=cut

Version data entries

105 entries across 38 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.1.11 lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.11 lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.11 lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.10 lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.9 lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.9 lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.9 lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.8 lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.8 lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.8 lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.7 lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.7 lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.7 lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.6 lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.6 lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.6 lib/javonet-ruby-sdk/Binaries/Perl/Linux/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.5 lib/javonet-ruby-sdk/Binaries/Perl/MacOs/X64/deps/lib/perl5/Attribute/Alias.pm
javonet-ruby-sdk-2.1.5 lib/javonet-ruby-sdk/Binaries/Perl/Windows/X64/deps/lib/perl5/Attribute/Alias.pm