How do you you check the return code of a command in perl?



How do you you check the return code of a command in perl?..

Answer / Preeti Sonker

In Perl, you can check the return code of a command using the system() function or backticks ``. Here is an example using system():n```perlnmy $command = 'ls -l';nsystem($command);nif ($?) {n print "The command returned an error with exit status: $?";n}n``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More CGI Perl Interview Questions

what is the main function of fork() in cgi programming?

1 Answers  


What is the difference between die and exit in perl?

1 Answers   HCL,


how to get back up from private character editor which is saved in the format of .udf

1 Answers  


Explain USE and REQUIREMENT statements?

1 Answers  


How to find the length of an array in perl?

1 Answers  


What are scalar data and scalar variables?

1 Answers  


What is the difference between perl array and perl hash?

1 Answers  


How to do comment in perl?

1 Answers  


What is the importance of perl warnings?

1 Answers  


Why we use CGI?

1 Answers   Wipro,


What are the characteristics of a project that is well suited to Perl?

1 Answers  


Explain the difference between my and local?

2 Answers  


Categories