#!/usr/bin/perl -wl use strict; for () { chomp; if (! /[^a-zA-Z0-9,]/ and ! /^,|,{2}|,$/) { print "Yep: $_"; } else { print "Nope: $_"; } } __DATA__ this,should,work,11 ,this,should,not,work this,,too,should,not,work nor,this,one,