phubuh has asked for the wisdom of the Perl Monks concerning the following question:

I was writing a JAPH, and decided to use \ as regex-delimiter to cause confusion. After i while i realized i needed to backwhack something, but since i had \ as delimiter, i could'nt. I can't find anything regarding this in documentation, i hope some wise monk will assist me. Thanks!

Replies are listed 'Best First'.
Re: Backwhacking with \ as delimiter
by BrotherAde (Pilgrim) on Aug 26, 2001 at 16:13 UTC

    I usually use any "weird" character which does not occur in the regex. My favourite is the tilde, not only for regexes, but also for print qq~I said "foo"~; constructs.

    BrotherAde

Re: Backwhacking with \ as delimiter
by John M. Dlugosz (Monsignor) on Aug 27, 2001 at 00:33 UTC
    Try interpolating it in from another string?
Re: Backwhacking with \ as delimiter
by BrentDax (Hermit) on Aug 27, 2001 at 08:41 UTC
    Normally I'd say "Don't use \ as a delimiter!" but this *is* a JAPH... :^)

    Perhaps you could do something clever with tr/// and eval:

    ($re='s\\foo~.bar\\foobar\\') =~ tr/\\~/~\\/; # ~ for \ eval $re;

    =cut
    --Brent Dax
    There is no sig.

Re: Backwhacking with \ as delimiter
by flocto (Pilgrim) on Aug 26, 2001 at 16:04 UTC
    I'd never use backslash ('\') as "regex-delimiter". All special characters are escaped with it so you'll just create confusion. Use the normal slash ('/') and you won't have any problems. I've seen '#' being used, too, but personally I don't like the look of it. But that might be just me..
      You could always still use the \ as a delimiter within $_, pass it through another substitution (s///) to replace it and then another to escape characters where necessary. Eval, rinse and repeat!
       
      Yes, it makes the process more convoluted, but then again with obfuscation, this can be a good thing! :)
       

       
      Ooohhh, Rob no beer function well without!