in reply to Substitution problem.

First of all, you're only using the /g flag, which will interpret your expressions literally and do interpolation. So you end up with this:
s/quotemeta('[')/quotemeta('x')/g;
Which presumably (if it were valid) would match the text "quotemeta'['", putting '[' into $1. Try doing this:
s/\Q$array1{$count}\E/$array2{$count}/g;
Or, if each array element simply has one character apiece (as you suggest), forego the loop entirely and use tr:
$from = join('', @array1); # or set up $from and $to $to = join('', @array2); # to begin with tr/$from/$to/; # e.g. "abc" =~ tr/ab/xy/ ==> "xyc"

Replies are listed 'Best First'.
Re: Substitution problem.
by Dominus (Parson) on Nov 25, 2000 at 08:47 UTC
    Says fastolfe:
    > tr/$from/$to/;
    This won't work, because variables are not interpolated inside of tr///. Your line replaces $ with $; f with t; and r, o, and m with o.
      Indeed, so that one would want to use:
      eval("tr/$from/$to/");
      More and more the only place I end up using eval is in this type of construction.

        I hope neither $from or $to have a / in them...

        I actually use eval for quite a few things. For instance I may want to turn a template into code and then eval that. But for "quick-n-dirty" I don't reach for it with the obvious exception of the /e modifier for substitutions.