in reply to RegExp Delimiter

It supports a bunch of them, basically anything you can dream up:
s/.../.../ s#...#...# s<...><...> s[...][...] s:...:...: s;...;...;
The same sort of rules apply to things like qr, qw, qq and qx. This gives you the freedom to choose something that won't collide.

On that note, though, the following seems to be valid Perl code, if a little awkwardly:
my $sql = qq{ SELECT id FROM ${table} };
It works as far as I can tell, but my syntax hilighter goes nuts on it, closing the string at the first instance of '}', which makes sense. Perl seems to be extra careful about interpolating.

Replies are listed 'Best First'.
Re: Re: RegExp Delimiter
by bart (Canon) on Sep 03, 2002 at 07:41 UTC
    On that note, though, the following seems to be valid Perl code, if a little awkwardly:
    my $sql = qq{ SELECT id FROM ${table} };
    It works as far as I can tell, but my syntax hilighter goes nuts on it, closing the string at the first instance of '}', which makes sense. Perl seems to be extra careful about interpolating.

    Perl takes balanced parens/brackets/braces/angles into account, that's why it works. Quoting from perlop:

        Non-bracketing delimiters use the same character fore and aft, but the
        four sorts of brackets (round, angle, square, curly) will all nest,
        which means that
    
                q{foo{bar}baz} 
    
        is the same as
    
                'foo{bar}baz'
    

    and it still goes on a bit. This is the perlop for 5.6.1. Older versions of this document aren't as elaborate, though they still mention that these pairs indeed do nest, at least up to the oldest version I found, v.5.004_05.

Re: Re: RegExp Delimiter
by demerphq (Chancellor) on Sep 03, 2002 at 10:18 UTC
    As japhy pointed out some time back the following also work
    s]...]...]; s)...)...); s}...}...};
    It works for al qq constructs. If you're interested peruse Japhys more recent nodes.

    Yves / DeMerphq
    ---
    Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)

      I know, I've already gotten some mileage out of it in a recent obfuscation of mine. Anything that makes the syntax highlighter choke has to be a step in the right direction for that sort of thing.
Re: Re: RegExp Delimiter
by Anonymous Monk on Sep 03, 2002 at 11:09 UTC
    Some syntax highlighters also have a distaste for constructs qq}like this}. And find one for me that will work properly after you apply Bleach. :-)