/usr/share/perl5/MMM/Common/Role.pm is in mysql-mmm-common 2.2.1-1.1.
This file is owned by root:root, with mode 0o664.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | package MMM::Common::Role;
use strict;
use warnings FATAL => 'all';
our $VERSION = '0.01';
use Class::Struct;
use overload
'==' => \&is_equal_full,
'eq' => \&is_equal_name,
'!=' => sub { return !MMM::Common::Role::is_equal_full($_[0], $_[1]); },
'ne' => sub { return !MMM::Common::Role::is_equal_name($_[0], $_[1]); },
'cmp' => \&cmp,
'""' => \&to_string;
struct 'MMM::Common::Role' => {
name => '$',
ip => '$',
};
#-------------------------------------------------------------------------------
# NOTE: takes a role object as param
sub is_equal_full($$) {
my $self = shift;
my $other = shift;
return 0 if ($self->name ne $other->name);
return 0 if ($self->ip ne $other->ip);
return 1;
}
#-------------------------------------------------------------------------------
# NOTE: takes a role object as param
sub is_equal_name($$) {
my $self = shift;
my $other = shift;
return ($self->name eq $other->name);
}
sub cmp($$) {
my $self = shift;
my $other = shift;
return ($self->name cmp $other->name) if ($self->name ne $other->name);
return ($self->ip cmp $other->ip);
}
sub to_string($) {
my $self = shift;
return sprintf('%s(%s)', $self->name, $self->ip);
}
sub from_string($$) {
my $class = shift;
my $string = shift;
if (my ($name, $ip) = $string =~ /(.*)\((.*)\)/) {
return $class->new(name => $name, ip => $ip);
}
return undef;
}
1;
|