#!usr/bin/perl -w use strict; while () { if(/\balpha\b/) { print "term 'alpha' detected on input line $.\n"; next; } .. do something here... .. sometimes better than elsif() } __DATA__ beta beta beta alpha # this line appears only once in the whole file beta beta beta