for example: 1. Input file: My name is $str1 I live in $str2 I like to eat $str1 2. Perl script #! /usr/local/bin/perl $str1 = "MIKE"; open(DB,"list.txt") || die "ERR: failed to open DB\n"; @all_lines = ; close(DB); @found = grep(/^My/,@all_lines); print @found,"\n"; #######################