in reply to split(/:/, $t) splits also on white space

As implied in the answer above, if you simply change (<@a>) to (@a) in your foreach loop, your code will work as you desire.

With the angle brackets the elements of the @a array ("A B", "C D") are being interpreted as a perl glob. Each element is split on whitespace, and the combined result is 4 total elements, A, B, C, and D. That's what your foreach loop iterates over and prints out.

  • Comment on Re: split(/:/, $t) splits also on white space