Subject: | Can't get it to work with objects |
This is a stripped down version of what I'm trying to do. Instead of printing 3, I get an uninitialized value. It works fine for me outside of objects:
#!/usr/bin/env perl
use warnings;
use strict;
use subs::parallel;
my $d = Data::Value->new(3);
$d->prime();
print $d->get(), "\n";
package Data::Value;
sub new {
my $class = shift;
my $value = shift;
return bless { value => $value }, $class;
}
sub prime {
my $self = shift;
$self->{cached} = parallelize {
return $self->{value};
};
# If I say "$self->{cached} = $self->{value};" it works fine
}
sub get {
my $self = shift;
return $self->{cached};
}
1;