Tuesday, July 23, 2019

Perl Notes

system()

Using the Perl system() function
The system() function returns two numeric values folded into one. The first is the Unix signal (e.g INT=2, QUIT=3, KILL=9), if any, that terminated the command. This is stored in the lower eight bits returned. The next higher eight bits contain the exit code for the command you executed.

The result is a compound numeric value, not a logical value. This also reads inverted and is confusing. If you need more information on error, then you can break up the return code:
my $status = system("rotate_quickly.pl"); 
my $signal = $status & 0xff; 
my $exit_code = ($status >> 8) & 0xff;


String

how to keep all special characters in a string?
the use of q() and quotemeta: stackoverflow post on excaping in perl

No comments:

Post a Comment

raspberry pi gpio controls

#gpiozero library https://gpiozero.readthedocs.io/en/stable/#