
DReiners
New User
Apr 22, 2004, 11:41 AM
Post #3 of 5
(9952 views)
|
Re: [jryan] Regex from external app
[In reply to]
|
Can't Post
|
|
True, but that's not the main problem (and not the problem I'm having right now ;). How do you get $1 to be interpreted on the substitution side when the whole substitution comes out of a string? Example: #!/usr/bin/perl $text="The quick brown fox"; $pat='quick (.*) fox'; $rep='quick fox, who is $1'; ($direct = $text) =~ s/quick (.*) fox/quick fox, who is $1/; ($indirect = $text) =~ s/$pat/$rep/; print "Direct: " . $direct . "\nIndirect: " . $indirect . "\n"; Output: Direct: The quick fox, who is brown Indirect: The quick fox, who is $1 Can anybody help with that? Thanks Dirk
|