Possible Duplicate:
perl “dollar sign and question mark” question
I am trying to understand the Perl script written by someone. I don’t understand the use of $? in the script. Can anyone explain me the purpose of below line?
system( "perform_task.sh", "-param1");
if( ( $? >> 8 ) != 0 ) {
print( "perform_task.sh failed " );
}
To find the meaning of any variable, you can either type
on the command line with relatively recent versions of Perl or scan
perldoc perlvarinstalled on your computer. Usually, it is best to read the documentation for the specific version ofperlyou have, but in a pinch, bearing in mind any possible gotchas due to version differences, the online version will do as well: perldoc -v ‘$?’:Further information can be gleaned from the documentation for perldoc -f system:
While there is nothing wrong with asking even elementary questions on Stackoverflow, if you actually want to become a capable programmer, you’ll need to get into the habit of reading the documentation yourself, and develop the capacity to understand it yourself.
Otherwise, you’ll waste valuable time you could be using to solve problems instead on waiting for others to read the documentation for you.
It really doesn’t affect the rest of us if you choose never to expend any effort in trying to understand documentation, but it will hurt you in the long run.