#!/usr/bin/perl undef $/; sub fileContainsWord() { my $file = $_[0]; my $word = $_[1]; my $found = 0; open FILE, "<$file"; while() { my $filecontents = $_; if($filecontents =~ /$word/smg) { $found = 1; last; } } close FILE; return $found; } my $file = "SearchSet.java"; my $word = "LEAD_TYPE."; my $flag = &fileContainsWord($file, $word); print $flag . "\n";