in reply to Selectively replacing characters inside a string

If I'm reading correctly that you want to replace all non-slash characters with the letter x, the easiest way would seem to be to use tr rather than a regex:
$ perl -e '$foo = "/some/path/to/a/file"; $foo =~ tr|/|x|c; print "$fo +o\n";' /xxxx/xxxx/xx/x/xxxx

Replies are listed 'Best First'.
Re^2: Selectively replacing characters inside a string
by markkawika (Monk) on Jun 11, 2009 at 16:42 UTC
    I do want to replace all non-slash characters with the letter x, but only on a portion of the input string. Specifically, the part between the quotes in file="some/path". And actually, I didn't make it clear, but there will be text before and after the file="some/path", so I have to be careful about what I substitute. The actual input line would look more like:
    2009-06-10 19:37:29 GMT [more text here] file="some/path" status=0 des +tination="some more text"
    And the only thing I want to filter is the path inside of the file="some/path" stuff.