in reply to Can you tell me why I get this error and if I can optimize my code somehow?

Probably because you used split with an expression that were empty or contained only newlines \n here:
@split_hit_non_barrel=split(/\n/, $separate_hit_non_barrel);

Since split absorbs its seperators, it would then return an empty list.
The first entry of an empty array would give an undef value:

$hit_line_non_barrel=$split_hit_non_barrel[0];

Using an undef value for a match would give a warning then:

$hit_line_non_barrel=~/^(.*?)\s+/
This is just guessing, using the Perl debugger would be much better. You can even customize the debugger, so it stops right at the point when the warnings occurs -> Re: Debugging a program and Re^3: Debugging a program allowing you to look what has gone wrong while having the whole context available. I am using this regularly with my code.

Replies are listed 'Best First'.
Re^2: Can you tell me why I get this error and if I can optimize my code somehow?
by Laurent_R (Canon) on Jun 21, 2014 at 10:07 UTC
    Thank you very much, hexcoder, for these very useful links on a debugging technique that I did not know so far and can save tremendous amount of debugging time. I for sure will be using it all the time from now on. I wish I could upvote your post more than once.