#!/usr/bin/perl -wl use strict; while () { chomp; print "$_ matched" if /^[^(?:cat)]/; } __DATA__ cat dog dog cat frog cat dog mouse dog cat cat dog elephant