Fixed perl critic issues.
Tidied.
Made regex a bit more readable.