package Disk; use strict; # constructor sub new { my $class = shift; my $device = shift; my $self = { 'device' => $device, 'info' => setInformation($device), # this is the method i want to be called }; bless $self, $class; } sub setInformation { my $self = shift; my $device = shift; my $model = qx(hdparm -i $device | grep -i model); $self->{'info'} = $model =~ /.*model=(.+?),.*/i; } sub getInformation { my $self = shift; return $self->{'info'}; }