in reply to Finding pages without specific words

I have played around with your program a little bit, here is my actual version, perhaps it is usefull for you:

#!/usr/bin/perl use strict; use warnings; use File::Find; my $dir = '\webdirectory'; my $nameOne = 'alpha beta'; my $nameTwo = 'charlie'; my @pages; sub mySub { return if -d $File::Find::name; return if $File::Find::name !~ /\.html$/; my $text; open (IN, $File::Find::name) or die "Can't open '$File::Find::name +': $!\n"; { local $/; # Slurp-Mode $text = <IN>; } close IN or die $!; if ($text !~ m/\Q$nameOne\E/ and $text !~ m/\Q$nameTwo\E/) { push @pages, $File::Find::name; } } find( \&mySub, $dir ); print "$_\n" for @pages;


I'm sorry for not using File::Slurp here as suggested, but its not installed here until now.

Replies are listed 'Best First'.
Re: Re: Finding pages without specific words
by Anonymous Monk on Mar 08, 2004 at 15:48 UTC
    Thanks to everyone! What is local $/ doing?
    open (IN, $File::Find::name) or die "Can't open '$File::Find::name': $ +!\n"; { local $/; # Slurp-Mode means what and what is local $/ d +oing?? $text = <IN>; }

      in perldoc perlvar you can find out more about $/ and the "slurp mode".
      Look for "input_record_separator"

      Sören