indeed, you explained the problem to the best of your knowledge. But, as RedRum already said, there's no problem with thodi's code.

However, you seem to get a "wrong" result. I think the problem is that your input strings in the @natsources array are already not the way you think they are. Whenever you expect some data to be in a certain way, but you're not sure, use the Data::Dumper module. It's part of standard Perl, and it's invalueable for debugging.

The problem was that every element in my array had a "\n" in front of it. I kind of fixed it by using "substr" to get the newline out. Now I have to figure out how to use this fix on all the elements.I'll try using "Data::Dumper" more often to see exactly what is happening with my arrays.