I think it is a lot easier for you to use Thread::Queue.
http://search.cpan.org/~jdhedden/Thread-Queue-2.11/lib/Thread/Queue.pm
If you want to understand, what you need to do for a shared array access, then look at the implementation of the module - it is very clear and clean and shows you that locking on arrays is more complex than you might expect.