I'm relatively new to perl, and there is an example code snippet in check_ilo2_health.pl that has a syntax snippet that I don't understand how or why this works. The code snippet processes the SSL client data, in this case XML, line by line.
if ( $line =~ m/MESSAGE='/) {
my ($msg) = ( $line =~ m/MESSAGE='(.*)'/);
if ( $msg !~ m/No error/ ) {
if ( $msg =~ m/Syntax error/ ) {
An example of the XML in question:
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
Thus, in this case, the if statement accepts the MESSAGE string of the XML sample. I understand that my ($ msg) treats the variable as a kind of list, and I understand how regular expressions match; however, I do not understand the syntax such that $ msg is assigned without errors. Perl seems to play with the syntax in parentheses, and it works for that. While it works, I would like to know how it works. Any help would be appreciated.
Burns source
share