if ( $realmonth >0 and $realmonth <=12 ) { print $monthname[$realmonth-1]; } else { warn "Invalid value for realmonth: $realmonth\n"; }