while () { $str = $_ ; if ($str =~ /include/) { if ($str =~ /\b$file_name\b/) { $flag = "TRUE" ; } } if ($flag eq "TRUE") { if ($str =~ /View Name/) { print $str ; ($junk,$view_name) = split(\->\,$str) ; print $view_name ; $flag = "FALSE" ; } } #print "$_\n"; }