while () { print "match on $1\n" if /^\S+ (\d+) \S+ \1$/; } __DATA__ foo 1000 bar 1000 foo 1000 bar 500