sub ReadPolicies { # based on the below command it reads values in array my ($type) = @_; my @Policies = `/opt/OV/bin/opctemplate -l | grep -i $type | awk '{print \$2}'`; return (@Policies); } #MAIN My @FailoverPolicies = &ReadPolicies(DBSPI); For (my $i=0; $i < @FailoverPolicies; $i++) { my $cmd "/opt/OV/bin/opctemplate -e" . " " . "$FailoverPolicies[$i]"; my $output= `$cmd`; # here i expect this command read each value from the array and take action, -e to enable }