Seems that you want to fill @subsetA and @subsetB based on the filenames contained in @fullarray.
I would propose the following apporach
- loop though each element of @fullarray
- use a regex to extract the relevant part of the filename (e.g. /(\d\d\d\d)\.tif)
- analyze the relevant part (e.g. use the modulo-operator (%) to get the reminder if of the number divided by 4)
- based on the result of the analysis, push the filename to one of your subsets
HTH, Rata