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