in reply to Having scalars handled as regexs inside a substitution
Note that $replace is defined via single quotes. That's to avoid interpolation in the assignment -- otherwise, there's an undefined value error.#!/usr/bin/perl -w use strict; my $string = "abcabcabc"; my $find = "a(bc)"; my $replace = '$1'; $string =~ s/$find/$replace/eeg; print ">>$string<<\n";
|
|---|