in reply to Splitting and formatting a line

Everybody else has posted some great comments on how to fix your code or do what you want in a cleaner way, but i don't think anyone has accutally explained the the "Use of uninitialized value" errors you've been getting, so here goes...

That error comes about when you try to do something with a value which is "undef". In your case, because you were trying to match on (..) (exactly two characters) your regex was failing, thus: $1..$5 were all undef, thus: "Use of uninitialized value" everytime you try to print one of those variables.