Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,35 @@
{
package Greeting;
sub new {
my $v = "Hello world!\n";
bless \$v, shift;
};
sub stringify {
${shift()};
};
};
{
package Son::of::Greeting;
use base qw(Greeting); # inherit methods
sub new { # overwrite method of super class
my $v = "Hello world from Junior!\n";
bless \$v, shift;
};
};
{
use Storable qw(store retrieve);
package main;
my $g1 = Greeting->new;
my $s1 = Son::of::Greeting->new;
print $g1->stringify;
print $s1->stringify;
store $g1, 'objects.dat';
my $g2 = retrieve 'objects.dat';
store $s1, 'objects.dat';
my $s2 = retrieve 'objects.dat';
print $g2->stringify;
print $s2->stringify;
};

View file

@ -0,0 +1,25 @@
use MooseX::Declare;
class Greeting {
use MooseX::Storage;
with Storage('format' => 'JSON', io => 'File');
has string => (is => 'ro', default => "Hello world!\n");
}
class Son::Of::Greeting extends Greeting {
has string => (is => 'ro', default => "Hello from Junior!\n");
}
my $g1 = Greeting->new;
my $s1 = Son::Of::Greeting->new;
print $g1->string;
print $s1->string;
$g1->store('object1.json');
my $g2 = Greeting->load('object1.json');
$s1->store('object2.json');
my $s2 = Son::Of::Greeting->load('object2.json');
print $g2->string;
print $s2->string;