Removing numbers from a text file

B

bob

What would be the most efficient way to remove numbers from a text
file.
eg. I want "abcde123fghi" to be "abcdefghi". Should load the file
into an array and create another file with characters that are not
numbers? With 100k character file for example that could take awhile.
Any suggestions?
thank you.
 
M

Martien Verbruggen

What would be the most efficient way to remove numbers from a text
file.

(untested)

$ perl -pi -e 's/\d//g' filename

or

$ perl -pi -e 'tr/0-9//d' filename

There might be more efficient ways, but I don't think it's worth looking
for them, so I won't.
eg. I want "abcde123fghi" to be "abcdefghi". Should load the file
into an array and create another file with characters that are not
numbers?

Why should it load the file into an array?
With 100k character file for example that could take awhile.

100k is nothing. Why do you think that "could take awhile'? What do you
define as acceptible performance? I'm sure the above on a reasonable
machine with 100k of input would run more than fast enough. Loading a
100k into an array or scalar and then doing the same would not take much
more or less time. In any case, it's unlikely you'd notice the
difference.

Martien
 
B

bob

Martien Verbruggen said:
100k is nothing. Why do you think that "could take awhile'? What do you
define as acceptible performance? I'm sure the above on a reasonable
machine with 100k of input would run more than fast enough. Loading a
100k into an array or scalar and then doing the same would not take much
more or less time. In any case, it's unlikely you'd notice the
difference.

Martien

Thanks for your tips. I'm brand new to perl and I've been and windoze
to long. I guess I've been corrupted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,138
Messages
2,570,804
Members
47,349
Latest member
jojonoy597

Latest Threads

Top