Q:

perl issuing os command with defined variables

I am adding functionality into my scripts so that they can use kerberos authentication to run automatically and use secure protocols when executing. I have my functionality working for shell scripts that do exactly what i want, however i am having issues porting it to perl to work within my perl scripts as i am new to perl. Here is my working shell code and trying to get the same functionality in perl:
#!/bin/sh
ticketFileName=`basename $0-$$` #set filename variable to name of script plus the PID
krb5CacheLocation=/tmp/$ticketFileName #set ticket cache location to /tmp + script name
/usr/share/centrifydc/kerberos/bin/kinit -c $krb5CacheLocation -kt /root/.ssh/someaccount.keytab someaccount #get TGT and specifiy ticket cache location on kinit
export KRB5CCNAME=$krb5CacheLocation #set the KRB5CCNAME variable to tell ssh where to look

What i have attempted in perl:
#!/usr/bin/perl
my $ticketFileName = `basename $0-$$`;
my $krb5CacheLocation = '/tmp/'.$ticketFileName;
`export KRB5CCNAME=$krb5CacheLocation`;
`/usr/share/centrifydc/kerberos/bin/kinit -c $krb5CacheLocation -kt /root/.ssh/someaccount.keytab someaccount`;

Seems it is not liking the passed variable that i am referencing in the OS command. Anyone have any ideas or suggestions?

A:

The, or a problem is that you establish KRB5CCNAME as an environment variable in a shell that's immediately thrown away.  michael has one alternative to this.  You could also pass the environment variable on the kinit invocation, with this syntax:
`KRB5CCNAME=$krb5CacheLocation /usr/share/centrifydc/kerberos/bin/kinit etc.`

Although as you throw away the output, just use system or, if this is also the last thing you'll be doing, exec:
exec "KRB5CCNAME=$krb5CacheLocation /usr/share/centrifydc/kerberos/bin/kinit etc."

A benefit of %ENV manipulation is that you can then use multi-argument exec.

