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++) { Print "/opt/OV/bin/opctemplate -e" . " " . $FailoverPolicies[$i], "\n"; $output= `/opt/OV/bin/opctemplate –e $FailoverPolicies[$i]`; # here i expect this command read each value from the array and take action, -e to enable }