You could do this in a couple of different ways.
The best would be to create the appropriate regular expression to clean the data as you want it, but another solution could be to do the following and then just add in a check for non-numeric characters in each column: I found this
here(http://perdoc.perl.org)
How do I extract selected columns from a string?
(contributed by brian d foy)
If you know the columns that contain the data, you can use substr to extract a single column.
my $column = substr( $line, $start_column, $length );
You can use split if the columns are separated by whitespace or some other delimiter, as long as whitespace or the delimiter cannot appear as part of the data.
my $line = ' fred barney betty ';
my @columns = split /\s+/, $line;
my $line = 'fred||barney||betty';
my @columns = split /\|/, $line;
If you want to work with comma-separated values, don't do this since that format is a bit more complicated. Use one of the modules that handle that format, such as Text::CSV , Text::CSV_XS , or Text::CSV_PP .
If you want to break apart an entire line of fixed columns, you can use unpack with the A (ASCII) format. By using a number after the format specifier, you can denote the column width. See the pack and unpack entries in perlfunc for more details.
my @fields = unpack( $line, "A8 A8 A8 A16 A4" );
Note that spaces in the format argument to unpack do not denote literal spaces. If you have space separated data, you may want split instead.
I haven't the time at the moment to create the regex for you as that would be my primary choice, or to update the code above to accommodate your question completely, but hopefully it can get you down the right path. I'll update my answer if I get a chance in the next couple of hours.