What you want to do is go through the array and if you get a match, put the element on the front of the array, otherwise put it on the end of the array. Reading through
marto's links above should make this clear.
Alternatively you can chose not to learn and use the code below
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."