#!/usr/bin/perl
my @pets = (
new Dog(name => "ぽち"),
new Cat
(name
=> "たま", sleep => 1) );
foreach my $pet (@pets) {
$pet->play();
}
use strict;
use warnings;
sub new {
my ($class, %args) = @_;
my $self = {
name => $args{name},
};
}
sub play {
}
sub new {
my ($class, %args) = @_;
my $self = Animal->new(%args);
}
sub play {
print "わんわん!" . $self->{name
} . "だよ\n"; }
sub new {
my ($class, %args) = @_;
my $self = Animal->new(%args);
}
sub play {
print "にゃあ!" . $self->{name
} . "だよ\n"; if($self->{sleep} == 1) { }
}
IyEvdXNyL2Jpbi9wZXJsCm15IEBwZXRzID0gKAogICAgICAgICAgICBuZXcgRG9nKG5hbWUgPT4gIuOBveOBoSIpLAogICAgICAgICAgICBuZXcgQ2F0KG5hbWUgPT4gIuOBn+OBviIsIHNsZWVwID0+IDEpCiAgICAgICAgICAgKTsKCmZvcmVhY2ggbXkgJHBldCAoQHBldHMpIHsKICAgICRwZXQtPnBsYXkoKTsKfQoKCnBhY2thZ2UgQW5pbWFsOwp1c2Ugc3RyaWN0Owp1c2Ugd2FybmluZ3M7CgpzdWIgbmV3IHsKICAgIG15ICgkY2xhc3MsICVhcmdzKSA9IEBfOwogICAgbXkgJHNlbGYgPSB7CgkJbmFtZSA9PiAkYXJnc3tuYW1lfSwKCSAgICAgICB9OwoKICAgIGJsZXNzICRzZWxmLCAkY2xhc3M7CiAgICByZXR1cm4gJHNlbGY7Cn0KCnN1YiBwbGF5IHsKICAgIG15ICRzZWxmID0gc2hpZnQ7Cn0KCgpwYWNrYWdlIERvZzsKdXNlIGJhc2UgcXcoIEFuaW1hbCApOwoKc3ViIG5ldyB7CiAgICBteSAoJGNsYXNzLCAlYXJncykgPSBAXzsKICAgIG15ICRzZWxmID0gQW5pbWFsLT5uZXcoJWFyZ3MpOwogICAgcmV0dXJuIGJsZXNzICRzZWxmLCAkY2xhc3M7Cn0KCnN1YiBwbGF5IHsKICAgIG15ICRzZWxmID0gc2hpZnQ7CiAgICBwcmludCAi44K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