in reply to Re^4: sort an array
in thread sort an array

Yeah, o.k., /x. I lose. ;-) But I wonder - was the OP using /x?

Replies are listed 'Best First'.
Re^6: sort an array
by Argel (Prior) on Mar 20, 2006 at 22:50 UTC
    It's probably becoming more prevalent as TheDamian recommends using xms for regex's in Perl Best Practices.

      Fascinating. I guess I'm more old-school than I thought.

      Now, x I could see. But m and s? You may as well say i and e while you're at it. Because it totally depends on what you're trying to do!

      We're building the house of the future together.
        Paraphrasing TheDamian:

        x- so that you can follow similar formatting/readabiliy guidlines as presented ealier in the book.PBP pg 236
        m- so that ^ and $ behave like most people expect (e.g. like in grep, sed, awk).PBP pg 237
        s- so that . matches anything like most people expect.PBP pg 240

        For example, which is easier to read?

        my $pattern = qr{HOSTNAME:\s*(?:\d{4}-)?\Q$hostname_for_regex\E(grbr-r +wan-x)\s+GRBR:\s*\Q$dev_ref->{grbr}\E}ixms;
        - or -
        my $pattern = qr{ # quoted regex HOSTNAME: # Literal text \s* # 0 or more whitespace (?:\d{4}-)? # Some devices begin with the router mode +l \Q$hostname_for_regex\E # Router hostname (grbr-rwan-x) \s+ # 1 or more whitespace GRBR: # Literal text \s* # 0 or more whitespace \Q$dev_ref->{grbr}\E # Just the GRBR }ixms;