Do you know where your variables are? | |
PerlMonks |
Re: Re: Re: Backticks, $?, and Sudoby sauoq (Abbot) |
on Jan 17, 2003 at 18:34 UTC ( [id://227761]=note: print w/replies, xml ) | Need Help?? |
Uhm... $! and $? do not act differently with sudo thrown in the mix. The only real difference is that you are executing a different command (i.e. sudo rather than the command that sudo is executing.)
In that case, sudo executed just fine and returned a 1 (which is what sudo does when the command it is given can't be executed.) Remember to shift $?. (256 >> 8 == 1)
Again, normal behavior. Perl can't execute the command given so it sets $? to -1 and returns the reason in $! (as documented.)
Once again, this behaved as expected. The command executed successfully, so $? contains 0. In this case, $! is not relevant. Keep in mind that $! is only meaningful in association with backticks and system when $? == -1. -sauoq "My two cents aren't worth a dime.";
In Section
Seekers of Perl Wisdom
|
|