How do I execute a shell command in perl if I call it through a sub routine?
For example, I can run this on the command line to get a particular value:
mycert-util --show test.user.myuser_cd
I want to run this command within a perl subroutine and call it. For example my routine would be get_auth and I want to print out the value of get_auth.
code:
use strict;
use warnings;
#&get_auth;
#get_auth();
print "The value is: get_auth() \n";
sub get_auth
{
$exec=`mycert-util --show test.user.myuser_cd`;
}
Your problem is not the sub, but how you call it. You cannot place sub calls inside quotes. Some equivalent alternative features below.