Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9245413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:15:45+00:00 2026-06-18T09:15:45+00:00

I am relatively new to perl and there is an example snippet of code

  • 0

I am relatively new to perl and there is an example snippet of code in check_ilo2_health.pl in which there is a piece of syntax that I do not understand how or why it works. The code snippet is parsing SSL client data, in this case XML, line by line.

if ( $line =~ m/MESSAGE='/) {
   my ($msg) = ( $line =~ m/MESSAGE='(.*)'/);  #<---- HERE

   if ( $msg !~ m/No error/ ) {
      if ( $msg =~ m/Syntax error/ ) {  #...etc

An example of the XML in question:

<RESPONSE
    STATUS="0x0000"
    MESSAGE='No error'
 />

So in this case the if statement takes the MESSAGE line of the XML sample. I understand that my ($msg) treats the variable as a sort of list and I understand how the regular expressions match; however, what I do not understand is the syntax such that $msg is assigned to No error. The perl seems to be playing around with parenthesis syntax and such for this to work. While it works I would like to know how it works. Any assistance would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:15:46+00:00Added an answer on June 18, 2026 at 9:15 am

    See Perlretut, Extracting-matches:

    … in scalar context, $time =~ /(\d\d):(\d\d):(\d\d)/ returns a true or false value. In list context, however, it returns the list of matched values ($1,$2,$3)

    So, in

    ($msg) = ( $line =~ m/MESSAGE='(.*)'/);
    

    ( $line =~ m/MESSAGE='(.*)'/) returns a list of the matches by the capturing groups. You have one capturing group, so the content of that is then stored in ($msg).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Relatively new to JQuery. I've got some code that does a banner swap with
I am relatively new to Perl and I do not want to use the
I'm relatively new to X Code and I m working on photo collage App
I'm relatively new to Java and I'm still trying to understand the fundamentals. I
I'm relatively new to SQL - I'm not sure if I'm doing this right.
Relatively new to python. I recently posted a question in regards to validating that
I'm relatively new to Perl, writing some XML parsing scripts. I have done two
Relatively new to PHP and I am uingd PHP to produce a table that
relatively new to python so excuse me if this has an obvious answer that
I am relatively new to Hibernate so I am still finding hard to understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.