Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Multiple line records from a command string

by molecules (Monk)
on Feb 23, 2010 at 17:33 UTC ( #824901=note: print w/ replies, xml ) Need Help??


in reply to Re: Multiple line records from a command string
in thread Multiple line records from a command string

(for Perceptor and others' sake)

In BrowserUK's code:

m[ Device \s Symmetrix \s Name \s+ : \s+ ( [^\n]+ ) .+? Device \s Serial \s ID \s+ : \s+ ( \d+ ) .+? KiloBytes \s+ : \s+ ( \d+ ) .+? SCSI-3 \s Persistent \s Reserve : \s+ ( \S+ ) .+? ]smx . . .

The regex flags smx mean the following:

s makes . match anything, including newlines. (In Perl, by default, . does not match newlines.)

m causes the characters ^ and $ to match, respectively, at the beginning and ending of lines instead of the beginning and ending of strings

x is for "Extended Formatting" or "Whitespace is not significant." Among other things, this allows the expression to span several lines without matching literal white space.

Using these three flags in Perl regexes is a best practice described by Damian Conway in Perl Best Practices pages 236-241.


Comment on Re^2: Multiple line records from a command string
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://824901]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-10-25 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (142 votes), past polls