
Replacing special chars with special chars
Quote:
> I would like to run through a file and replace a set of
> special chars (i only have the hex values) with other
> special chars..
> trying to overcome the windows special char codes and
> the unix special char codes difference.
Read the data, and use 'tr' for each chunk of
data (line/record/whatever the chunk you read).
If, say I had such a chunk in the scalar $chunk,
and I wanted to replace each byte with the hex
value of E4 with, say, D0, then I could do it
with
$chunk =~ tr!\xE4!\xD0!;
See also the Perl Frequently Asked Question (FAQ):
"How do I change one line in a file/delete a line
in a file/insert a line in the middle of a file/
append to the beginning of a file?"
It'll show you the general procedure required for
replacing stuff in a file with other stuff.
You'll find the FAQ in your Perl documentation
directories, or via http://www.perl.com
regards,
ICL Data Oy
Finland