An advantage of storing messages in the above manner is that the same message can be shared by different parts of the code. Another is that when the message content is changed, the change is effected in all the places it's used.

One disadvantage is that you don't know what a message is unless you look it up in the array. For example, if $msg5 is used somewhere in the code, after a while you tend to forget what it is and have to look at the array code to figure it out. This problem becomes obvious when you have lots of such messages or when the array is stored in another file.

If you want to store messages globally, as in your code, think about using a hash instead of an array. $msg{'cracker'} is more human-readable than $msg[2], especially when your code is long and you don't want to look up the exact ID of a message.
Cheers,CombatSquirrel.
Entropy is the tendency of everything going to hell.

This way you could build goodies into the function that allows clever stuff to happen - such as checking which language to return the message in - not to mention croaking if you ask for a message that does not exist.

It would also make sense to store your messages centrally in an XML or YAML file as suggested above.

you listed the advanteges and disadvanteges youself.
when unsing the same messages over and over again in a large script it makes sense to do the array thing you showed.
however in a smal script where you just have to print a small number of messages and using them mostly once it whould make sense to print them directly where you whant them whithout unsing scalars.
i think it depends on the circumstances.