On Aug 28, Beau E. Cox said: >I can't figure this one out. I have a requirement >to grab from some sort of input the elements of a regular >expression and execute it. All is fine except when I use >$1, $2, ... in the substitution, as:
This is in the FAQ, and one of the MOST commonly asked FAQs I've ever seen. perldoc -q expand How can I expand variables in text strings? [...] Long story short: $m = '(\w+)\s+(\w+)'; # should consider using qr/(\w+)\s+(\w+)/ instead $r = '"$1 $2"'; s/$m/$r/ee; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]