in reply to Print every past three months from current month

This might help:
my @three_months; for (1..3) { $month_number--; $month_number ||= 12; unshift(@three_months,$month_number); }