for (@_) { do { # stuff to do here } while (/\.dat/); } #### for (@_) { if (/\.dat/) { # stuff to do here } }