in reply to evaluating $1 in a replace string
Update Well, I thought doing a s///e on it would be the ticket, but apparently not. I'll keep working on it though. :-)
Update: The following code will work, you just have to change your placeholder from $1 to %s.
Yes, it does place some limitations depending on how you are going to use it, but that's life. :-)#!/usr/bin/perl -w use strict; my $find = 'proof(\S+)'; my $rpl = 'read%s'; my $text = 'proofing is proof it needed to be proofed'; if ($text =~ s/$find/ sprintf($rpl,$1) /e) { print "1st replacement made:\n\t$text\n"; }
-caedes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: evaluating $1 in a replace string
by dvergin (Monsignor) on Jul 08, 2002 at 05:53 UTC | |
by Fletch (Bishop) on Jul 08, 2002 at 11:41 UTC | |
by Oaks (Novice) on Jul 08, 2002 at 06:24 UTC |