On Monday, March 10, 2014 12:09:22 PM UTC-5, Joachim Schrod wrote:
>
> On 03/10/14 15:37, Matt Zagrabelny wrote: 
> > On Sun, Mar 9, 2014 at 5:58 PM, Teoh khah swee 
> > <[email protected]<javascript:>> 
> wrote: 
> >> HI all, 
> >> 
> >> I just come across an case statement for puppet. I would like to know 
> what 
> >> the means of the mx for below sample code? 
> >> 
> >> case $::operatingsystem { 
> >>    /(?-mx:AIX)/ :{ 
> > 
> > From: 
> > 
> > http://perldoc.perl.org/perlre.html 
> > 
> > (?adlupimsx-imsx) 
> > (?^alupimsx) 
> > One or more embedded pattern-match modifiers, to be turned on (or 
> > turned off, if preceded by - ) for the remainder of the pattern or the 
> > remainder of the enclosing pattern group (if any). 
> > 
> > (?adluimsx-imsx:pattern) 
> > 
> > m: 
> > Treat string as multiple lines. That is, change "^" and "$" from 
> > matching the start or end of line only at the left and right ends of 
> > the string to matching them anywhere within the string. 
> > 
> > x: 
> > Extend your pattern's legibility by permitting whitespace and comments. 
> > 
> > I would then say that puppet is looking for AIX without capturing it 
> > and has turned off the m and x options for this pattern match. 
>
> I don't know if Ruby regexps are really exactly the same as Perl 
> regexps, but, to me as a Perl programmer, this regexp looks 
> semantically identical to /AIX/, just with some added garbage to 
> irritate people who don't know enough about regexps... ;-) 
>
>

There's no need to speculate about Perl vs. Ruby (vs. Puppet) regexes, when 
instead we can go straight to the docs: 
http://docs.puppetlabs.com/puppet/3/reference/lang_datatypes.html#regular-expressions.
  
We see there that Puppet accepts options m, x, and i, which have the same 
meaning to Puppet as to Ruby and Perl (multiline mode, (in)significant 
whitespace/comment mode, and case-insensitive mode, respectively).

Since all these options are off by default, Joachim is right: the regex 
presented means exactly the same thing as /AIX/, and explicitly declaring 
the options off does nothing but obfuscate.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/662b5fe8-5a7a-46e9-b11b-9ee5af669206%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to