/^\Q$host\E$/; ^ ^ ^^ | | || | | |+ - End of line | | + - End quote metacharacters | + - Begin quote metacharacters (e.g., [.*\+], etc.) + - Match beginning at the start of the line #### use warnings; use strict; my $host = 'db'; while () { print if /^\Q$host\E$/i; } __DATA__ db db4323 dbwindows822.tp.com db726.tp.com #### db #### db db4323 dbwindows822.tp.com db726.tp.com