in reply to array problem
This will remove and use the first element of @arr as a replacement. Note the addition of the 'e' modifier, to evaluate the replacement expression.
Not sure why using @arr in s// yields a single item. The item it picks seems to be arbitrary as well.
Also, shoot for 'use strict;' on all your programs and quit using global variables.