The day of the year is in the array returned by localtime() (see perlfunc/"localtime"):
$day_of_year = (localtime(time()))[7];