Peeking into attributes breaks encapsulation. It shouldn't be done under normal circumstances, so I'd consider it OK one needs to be wordy to tell others to do it.
With the new class feature, objects are no longer blessed hash references and their attributes (now called fields) can't be accessed without accessors, anyway.
#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
use 5.039.010;
use experimental 'class';
class My {
field $x :param :reader;
}
my $o = 'My'->new(x => 10);
say $o->x; # No other way.
Update: Fixed a typo, thanks LanX.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
|