use strict; use warnings; { package testor; sub new { my $class = shift; return bless { component_name => $_[0], }, $class; } sub component_name { my $self = shift; return $self->{component_name}; } sub isExist { my $self = shift; return 0; } } my $myComponent = '7-Zip 9.20 (x64 edition)'; my $checker = testor->new($myComponent); if( $checker->isExist ) { print $checker->component_name, " already installed\n"; } else { print $checker->component_name, " not installed\n"; }