- or download this
use Util::H2O;
my $hash = h2o { foo => "bar", x => "y" }, qw/ more keys /;
print $hash->foo, "\n"; # prints "bar"
$hash->x("z"); # setter
- or download this
my $struct = { hello => { perl => { world => "yay" } } };
h2o -recurse, $struct;
print $struct->hello->perl->world, "\n"; # prints "yay"
- or download this
my $obj = h2o -meth, {
one => 123, two => 456,
...
return $self->one + $self->two;
} };
print $obj->sum, "\n"; # prints "579"
- or download this
h2o -class=>'Point', -new, -meth, {
angle => sub { my $self = shift; atan2($self->y, $self->x) },
...
my $two = Point->new(x=>3, y=>4);
$two->y(5);
printf "%.4f\n", $two->angle; # prints 1.0304