Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Finding pages without specific words

by Crian (Curate)
on Mar 08, 2004 at 13:35 UTC ( [id://334798]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://334798]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found