In this example for perl book, where is "_components" coming from? I know adding _ to indicate sub is private to the package but this one seems to use leading score out of nowhere. Can you please point me to some source about this? thank you.
package Computer;
@ISA = qw(StoreItem);
sub new {
my $pkg = shift;
my $obj = $pkg->SUPER::new("Computer", 0,0);
$obj->{_components} = [];
$obj->components(@_);
$obj;
}
sub components {
my $obj = shift;
@_ ? push (@{$ojb->{_components}}, @_) : @{$obj->{_components}};
}
sub price {
my $obj = shift;
my $price = 0;
my $component;
for my $component ($obj->components()) {
$price += $component->price();
}
$price;
}
question from:https://stackoverflow.com/questions/65645504/dynamically-add-leading-underscore-to-existing-sub