sub fn { my ($str) = @_; my $rStr = \$str; my $rParam0 = \$_[0]; #print "params=<@_> param0=$rParam0 <$str> copy=$rStr\n"; printf "\\\$1=<%s> \\\$_[0]=<%s> str=<%s> \$1=<%s>\n" , \$1, \$_[0] , (defined($str) ? $str : 'undef') , (defined($1) ? $1 : 'undef'); $str =~ s/x//; printf "\\\$1=<%s> \\\$_[0]=<%s> str=<%s> \$1=<%s>\n" , \$1, \$_[0] , (defined($str) ? $str : 'undef') , (defined($1) ? $1 : 'undef'); } $_ = "x"; s/(x)/fn $1/e; #### \$1= \$_[0]= str= $1= \$1= \$_[0]= str=<> $1=