C:\Users\Bill\forums\monks>type gopikavi.pl use strict; use warnings; open my $F, '<', 'file.txt' or die $!; my $text = do{ local $/ = undef; <$F> }; print 'Enter the name: '; chomp( my $name = <> ); if ($text !~/\b$name\b/){ die "Word '$name' is not in file 'file.txt'\n"; } print $text; C:\Users\Bill\forums\monks>perl gopikavi.pl Enter the name: data1 data1 data2 data3 data4 C:\Users\Bill\forums\monks>perl gopikavi.pl Enter the name: data5 Word 'data5' is not in file 'file.txt'