Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pattern Matching help

Posted on 2007-11-20
4
Medium Priority
?
265 Views
Last Modified: 2010-04-21
Please explain following line of perl code in detail.  Earlier in code TEMP handle has debugging information.  A line at a time is assigned to line macro from TEMP handle until TEMP handle reaches EOF.


if ($line =~ m/.+:\s+TAG\_compile\_unit/)
{
   ...
}
0
Comment
Question by:naseeam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 2000 total points
ID: 20323689
This is checking to see if the variable $line matches a pattern, and if so, do something.

The pattern:
m/                                  Starts of pattern.  When using / as the delimiter, the m is optional
.+                                   Any character except \n, 1 or more times
:                                    The colon character
\s+                                Whitespace (space, tab), 1 or more times
TAG\_compile\_unit       the string "TAG_compile_unit".  The \ are not necessary here
/                                    End of the pattern
0
 
LVL 1

Author Comment

by:naseeam
ID: 20323760
What is =~ in the above if condition?

Thanks.
0
 
LVL 1

Author Closing Comment

by:naseeam
ID: 31410235
Quick Response.  Accurate detailed answer.
0
 
LVL 39

Expert Comment

by:Adam314
ID: 20323992
That is used to do match the thing on the left ($line in your case) with the pattern on the right.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question