You repeat the error throughout the code. But, I can spot a couple of other problems:
in the elsifs you are missing the $ on numPics
your final else is missing the braces around the statement.
use strict would have found all these problems, and is a neccessity for beginning perl programmers.