use warnings; use strict; my $host = 'db'; while () { print if /^\Q$host\E$/i; } __DATA__ db db4323 dbwindows822.tp.com db726.tp.com