rmexico has asked for the wisdom of the Perl Monks concerning the following question:
and the perl code that i'm using to find a word in that file:package blah.blah.blah; import blah.Log; public void addLeadType(LEAD_TYPE type) { _leadTypes.add(type); } // ** PROTECTED METHODS // ** PRIVATE METHODS // ** ACCESSORS // ** INNER CLASSES }
for some reason, it's not picking up the trailing dot in $word, and flag is coming back '1' why is this?#!/usr/bin/perl undef $/; sub fileContainsWord() { my $file = $_[0]; my $word = $_[1]; my $found = 0; open FILE, "<$file"; while(<FILE>) { 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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex: finding something followed explicitly by a dot
by brian_d_foy (Abbot) on Feb 11, 2006 at 17:15 UTC | |
|
Re: regex: finding something followed explicitly by a dot
by davido (Cardinal) on Feb 11, 2006 at 17:14 UTC | |
|
Re: regex: finding something followed explicitly by a dot
by bart (Canon) on Feb 11, 2006 at 17:15 UTC | |
|
Re: regex: finding something followed explicitly by a dot
by m.att (Pilgrim) on Feb 11, 2006 at 17:19 UTC | |
|
Re: regex: finding something followed explicitly by a dot
by pKai (Priest) on Feb 11, 2006 at 17:27 UTC | |
|
Re: regex: finding something followed explicitly by a dot
by ayrnieu (Beadle) on Feb 12, 2006 at 00:33 UTC | |
by shenme (Priest) on Feb 12, 2006 at 15:29 UTC | |
by ayrnieu (Beadle) on Feb 12, 2006 at 21:27 UTC |