Stas et al, OK. Gave this a try:
file:MyApache/BlockByIP.pm -------------------------- package MyApache::BlockByIP; use strict; use warnings; use Apache::RequestRec (); use Apache::Connection (); use Apache::Const -compile => qw(FORBIDDEN OK); my %bad_ips = map {$_ => 1} qw(127.0.0.1 10.0.0.4); sub handler { my $r = shift; return exists $bad_ips{$r->connection->remote_ip} ? Apache::FORBIDDEN : Apache::OK; } 1; I'm pretty OK with this, but let me ask two questions: Question 1: When I commented: # use Apache::Connection (); I got an error: [Sat Jul 03 17:21:31 2004] [error] [client 127.0.0.1] Can't locate object method "remote_ip" via package "Apache::Connection" at /home/darnold/modperl/MyApache/BlockByIP.pm line 17.\n But when I commented: # use Apache::RequestRec (); No error! How come? Question 2: I am shaky with this line: use Apache::Const -compile => qw(FORBIDDEN OK); What's that "compile" thingy and can someone break down the use of the => notation in this situation for me? At 04:33 PM 7/3/04 -0700, Stas Bekman wrote: >[David, don't forget to hit reply-all] > >> Thanks. Line continuation! >> >> I now have this in my httpd.conf: >> >> <Location /public> >> PerlAccessHandler 'sub {\ >> return Apache::Const::FORBIDDEN\ >> unless >> shift->connection->remote_ip=~m/^\Q10.3.4./;\ >> }' >> </Location> >> >> Hmmm.... I'm reading this and it seems to me that this should deny access >> to anyone trying to access a file in the /public folder unless they are >> coming from a remote address that starts with 10.3.4. But it seems to let >> me in coming from 127.0.0.1. >> >> Am I missing something here? > >Your code is broken, there is no Apache::Const::FORBIDDEN, but >Apache::FORBIDDEN. You also need to compile it before you can use it. Take a >look at: >http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlAccessHandler > >did you look at the error_log file, was there anything in it? > >add 'use warnings/use strict' or PerlOptions -w (and -T) if you don't have >already. > >-- >__________________________________________________________________ >Stas Bekman JAm_pH ------> Just Another mod_perl Hacker >http://stason.org/ mod_perl Guide ---> http://perl.apache.org >mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com >http://modperlbook.org http://apache.org http://ticketmaster.com > >-- >Report problems: http://perl.apache.org/bugs/ >Mail list info: http://perl.apache.org/maillist/modperl.html >List etiquette: http://perl.apache.org/maillist/email-etiquette.html > > > -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html