At 06:47 PM 12/6/2005 +0300, 
>my $str = 'lazha';
>my $pattern = 'la(zh)(a)';
>my $replacement = '$1o"p$2';
>$str =~ s/$pattern/$replacement/;
>print $str;
>I want zho"pa to be printed. So far it is obviously '$1o"p$2'. eval (as well 

I think ur going about this the wrong way.  I'm guessing that u want to
first search for the pattern, and then substitute based on anything it found.

$str = 'lazha';
$pattern = qr/la(zh)(a)/;
$str =~ m/$pattern/;
if ($1 and $2) {
        $replacement = "$1o\"p$2";
        $str =~ s/$pattern/$replacement/;
}
print "$str\n";
######
zho"pa

Or as a one-liner:
$str =~ s/la(zh)(a)/$1o"p$2/;   # same thing

Excessive way:
$str = 'lazha';
$pattern = qr/la(zh)(a)/;

$str =~ s/$pattern/&rep($1,$2)/e;
print "$str\n";

sub rep {
return "$_[0]o\"p$_[1]";
}











--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede malis"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to