if( $INPUT{'checked_ids'} !~ /^(\d+(, +)?)+$/ ){ # you have bad data }