How can I find extended ASCII characters in a file using Perl? Can anyone get the script?
…..thanks in advance…..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since the extended ASCII characters have value 128 and higher, you can just call ord on individual characters and handle those with a value >= 128. The following code reads from stdin and prints only the extended ASCII characters:
Alternatively, unpack together with chr will also work. Example:
(I’m sure some Perl guru can condense both of these to two one-liners…)
To print the line numbers instead, you can use the following (this does not remove duplicates, and will have odd behaviour when unicode is passed):
(Thanks Yaakov Belch for the
$.tip.)