Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Character Processing Pt. 2

3 views
Skip to first unread message

Jackson White

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to
What i need the perl command to do is to go thru every single
character, if it's not (a-z,A-Z, 0-9, all punctuations), remove them
from the text files.

perl -pi -e 'tr/a-zA-Z0-9//cd' file1

the above line was given by Uri Guttman (thanks!), for my initial
request for a-zA-Z0-9.

I need to modify the above line to suit my new requirements. Tried
reading up on the docs for perlop, especially tr, but i don't
understand it.

Any assistance is much appreciated!


Sent via Deja.com http://www.deja.com/
Before you buy.

Jon Ericson

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to
In article <83mpms$u7e$1...@nnrp1.deja.com>,

Jackson White <myth...@my-deja.com> wrote:
> What i need the perl command to do is to go thru every single
> character, if it's not (a-z,A-Z, 0-9, all punctuations), remove them
> from the text files.

You need to to be more specific about 'all punctuations'. Do you mean
ordinary English punctuation like ',.!:;?"', or symbols on your keyboard
('~`@/<>{}^'), or printable characters, or ...


> perl -pi -e 'tr/a-zA-Z0-9//cd' file1
>
> the above line was given by Uri Guttman (thanks!), for my initial
> request for a-zA-Z0-9.

Looks like you are almost there. Throw in the other characters you want
to purge form the file and you're done.

> I need to modify the above line to suit my new requirements. Tried
> reading up on the docs for perlop, especially tr, but i don't
> understand it.

If you read perlop and didn't understand parts of it, I am sure that the
folks who maintain the Perl documents would love to hear specific and
constructive criticism. (Such as: "I thought that 'perlop_sentence'
meant that I could write 'perl_statement' and get 'some_result', but
instead I get 'nother_result'.) If you read perlop and didn't
understand any of it, perhaps you should pick up a beginning Perl book
like Learning Perl (the Llama book). I skimmed through the section on
the transliteration operator (section 15.5) and found it to be easy
reading. If you expected perlop to tell you precisely how to do what
you want to do, perhaps you should ask your local mind-reader/Perl-guru.
:)

Jon
--

0 new messages