in reply to To split with spaces

Thank you, but I tried and tested substr and unpack functions. These are not working. Because our input data is not a fixed-column format. Some of columns have whitespace characters and substr and unpack functions ignore these whitespace characters and pick up next columns...

The pack and substr functions don't ignore white spaces. But given that they work with positions within the string, they may have trouble solving mixtures of whites spaces and tabulations (because a tab takes only one position in a string, but usually several on the printed line). This is at least my hypothesis # 1, by far the most likely in my eyes. But you could also have some other nasty invisible characters (backspace and what not), which we cannot guess with the copy and paste that you are providing so far.

We really need to know exactly and in detail what you raw file looks like (unformated). Either make the file available by some means so that we can download it and look at it, or possibly supply an hex dump of it (although this is less practical).

Meanwhile, you could also try to split your records on single tabs, rather than spaces, and see what you get. Changing your original code to something like this:

@fields = split /\t/, $line;

It might just be the solution.