in reply to Cleaning a text file
Just loop through each line and substitute everything that not one of those characters (or a tab!) with nothing. This program takes names of the files from the command line and prints the result to standard output (which you can then redirect). Don't use this on the original data until you're sure it does what you want. In the regular expression, the \d and _ that you want are part of \w.
#!/usr/bin/perl while( <> ) { s/[^\w ,.()\t-]+//g; print; }
You can also do this from the command line with perl's in-place editing feature. Again, make sure you have your original data in a safe place even though this creates a backup ffile for you.
perl -pi.old -e 's/[^\w ,.()\t-]+//g' input_file
|
|---|