Day 14: What $! The $? (Proc::ChildError)
About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.
Finding out OS error message in Perl is pretty straightforward: just print out the $! variable. Example:
open my $fh, ">", "somefile" or die "Can't open file: $!";
The $! is pretty magical, it can return an integer (errno) or a string.
However, finding out child error message is not equally straightforward: there needs to be some bit-fiddling involved, which I always forget. To quote the perlvar manpage (or, perldoc -f system):