in reply to RegEx Perl Code
It just needs some repair for syntax problems:
Your parens in $regex weren't closed. I added qr// because it's a good thing to do, and some dots to match and a substitution just to demonstrate.#!/usr/bin/perl $regex = qr/(?{print "Hey!";}).../; $string = "some word"; $string =~ s/some($regex)/$1 x 5/e; print $string,$/;
Update: The 'quote regex' operator, qr//, precompiles the regex before storing it. That improves performance in the same way as m//o and s///o, but the result is stored rather than scoped as /o is. Precompilation gains nothing if the regex is only used once, but if the regex is to be stored in a variable anyway, it does no harm that I know of.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RegEx Perl Code
by Abigail-II (Bishop) on Jul 23, 2002 at 12:28 UTC | |
|
Re: RegEx Perl Code
by Abigail-II (Bishop) on Jul 23, 2002 at 17:23 UTC | |
by Anonymous Monk on Jul 25, 2002 at 02:21 UTC | |
by jryan (Vicar) on Jul 23, 2002 at 23:14 UTC | |
by Abigail-II (Bishop) on Jul 24, 2002 at 08:53 UTC |