All I can say is that why did I spend the past 2 days trying to figure it out myself??!! I should come here earlier.
No, what you did is correct, you have to try out something of yourself first, otherwise you wouldn't have had the taste of regular expressions in that process.
moreover IMO, pack/unpack are not easier ones to understand and use for any Perl newbies!.
Good that you have got your solution, but never forget to try yourself and then come here for clarifications; we love to clarify such doubts.

Vivek
-- 'I' am not the body, 'I' am the 'soul', which has no beginning or no end, no attachment or no aversion, nothing to attain or lose.