File: synopsis.pl

package info (click to toggle)
libmoosex-arrayref-perl 0.005-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 172 kB
  • sloc: perl: 249; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (5)
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
  {
    package Local::Person;
    use Moose;
    has name => (
      is    => 'ro',
      isa   => 'Str',
    );
    __PACKAGE__->meta->make_immutable;
  }
  
  {
    package Local::Marriage;
    use MooseX::ArrayRef;
    has husband => (
      is    => 'ro',
      isa   => 'Local::Person',
    );
    has wife => (
      is    => 'ro',
      isa   => 'Local::Person',
    );
    __PACKAGE__->meta->make_immutable;
  }
  
  my $marriage = Local::Marriage->new(
    wife      => Local::Person->new(name => 'Alex'),
    husband   => Local::Person->new(name => 'Sam'),
  );
  
  use Data::Dumper;
  use Scalar::Util qw(reftype);
  print reftype($marriage), "\n";   # 'ARRAY'
  print Dumper($marriage);