Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

remove characters by hex code

by davidj (Priest)
on Jan 04, 2005 at 23:15 UTC ( [id://419448]=perlquestion: print w/replies, xml ) Need Help??

davidj has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,
I should know how to do this, but I don't, so please forgive me. I have some text files with characters whose hex codes are 91, 92, and 97. I want to substitute these characters with other characters. How do I go about doing this? I'm guessing I need to use pack, but I'm uncertain how to do it.

As always, many thanks for your assistance,

davidj

Replies are listed 'Best First'.
Re: remove characters by hex code
by gaal (Parson) on Jan 04, 2005 at 23:21 UTC
    Your file is in an 8-bit encoding, yes? Make sure perl thinks so too, then use \x for the substitution.

    #!/usr/bin/perl -C0 # (see -C in perlrun) # [...] y/\x91\x92\x97/omg/; # or some other three replacement chars
      Thank You.

      davidj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://419448]
Approved by sgifford
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-29 10:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found