Recommendations: avoid the shell, use automatic error handling - IPC::System::Simple .
require IPC::System::Simple; use autodie qw(:all); system qw(command --arg1=arg1 --arg2=arg2 -arg3 -arg4);
use IPC::System::Simple qw(runx); runx [0], qw(command --arg1=arg1 --arg2=arg2 -arg3 -arg4);
Edit: an inscription appears.
eugene y answer contains a link to the documentation in the system. There we can see a piece of code that needs to be included every time to make the system correct. eugene y answer shows, but part of it.
Whenever we are in this situation, we collect duplicate code in a module. I draw parallels with the correct exception handling using Try::Tiny , however IPC::System::Simple , since the system done correctly, did not see this quick adoption from the community. It seems to need to be repeated more often.
So use autodie ! Use IPC::System::Simple ! Save boredom, be sure to use proven code.
daxim
source share