- or download this
sub new {
my ($class,%data) = @_;
return bless \%data, $class;
}
- or download this
use Acme::Playmate;
...
print "Details for playmate " . $playmate->{ "Name" } . "\n";
print "Birthdate" . $playmate->{ "BirthDate" } . "\n";
print "Birthplace" . $playmate->{ "BirthPlace" } . "\n";
- or download this
package Some::User;
...
sub user { die "user() must be implemented in subclass" }
sub pass { die "pass() must be implemented in subclass" }
sub url { die "url() must be implemented in subclass" }
- or download this
package Some::User::Foo;
sub user { 'bob' }
sub pass { 'seKret' }
sub url { '<a href="http://somesite.com/">http://somesite.com/</a
+>' }
- or download this
my $foo = Some::User->new('Foo');
- or download this
print $office->manager->name;
- or download this
print $office->manager_name; # manager_name calls $manager->name
- or download this
foreach my $tender (@tenders) {
$tender->apply($order);
}
- or download this
$object->{foo};
- or download this
$object->foo;
$object->set_foo($foo);
- or download this
if ($object->error) {
$object->log_errors
} # bad!
- or download this
sub log_errors {
my $self = shift;
return $self unless $self->error;
$self->_log_errors;
}
- or download this
sub connect {
my $self = shift;
unless ($self->_get_rss_feed) {
...
}
$self;
}
- or download this
$object->set_foo( $object->get_foo );
- or download this
--- #YAML:1.0 !perl/Product
bin: 19
...
id: 7
inv: 22
modified: 0
- or download this
Product 7
Name: Shirt
...
On-hand: 22
Bin: Aisle 3, Shelf 5b (19)
Record not modified
- or download this
sub new {
my ($class, %data) = @_;
bless \%data => $class;
}
- or download this
sub set_some_property {
my ($self, $property) = @_;
$self->{some_prorety} = $property; # (sic)
...
}
sub some_property { $_[0]->{some_property} }
- or download this
ok($object->set_some_property($foo), 'Setting a property should su
+cceed');
is($object->some_property, $foo, "... and fetching it should a
+lso succeed");