Perl Question 
Author Message
 Perl Question

Hello, I am revising my own messageboard script because I found a small
error. I made it so that when the Perl script is executed it has to match a
URL as its referrer. However, I have found that I need to incorporate two
more URL's because they also legitimate. I have learned basics in Pascal,
Perl, BASH, C++, Visual Basic, HTML, PHP, and Java so I am not sure what
coding to use. The statement that needs to be revised is:

if ($ENV{HTTP_REFERER} eq
" http://www.*-*-*.com/ ;)

How can I make it have other possibilities for a match? My best guess would
be:

if ($ENV{HTTP_REFERER} eq
" http://www.*-*-*.com/ ; ||
" http://www.*-*-*.com/ ;)
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Wed, 25 Jun 2003 13:02:48 GMT  
 Perl Question
Your question was sent to too many mailing lists.

Your question was sent to lists that were not applicable; the perl/tk
mailing list is for perl/tk -- generally not for generic perl
questions. You may want to consider reading some CPAN perl code -- some
examples are great for learning.


Quote:
> if ($ENV{HTTP_REFERER} eq
> "http://www.shadowcreek.org/messageboard/mbwrite.cgi" ||
> "http://shadowcreek.org/messageboard/mbwrite.cgi")

This would always be true. Do the test for both, such as:

 if ($ENV{HTTP_REFERER} eq
     "http://www.shadowcreek.org/messageeboard/mbwrite.cgi" ||
     $ENV{HTTP_REFERER} eq
     "http://shadowcreek.org/messageboard/mbwrite.cgi") {
 }

Of course, in perl numerous techniques can accomplish what you want.

Good luck,

   Jeremy C. Reed
   http://www.reedmedia.net/

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Wed, 25 Jun 2003 14:23:31 GMT  
 Perl Question

Quote:

> Hello, I am revising my own messageboard script because I found a small
> error. I made it so that when the Perl script is executed it has to
match a
> URL as its referrer. However, I have found that I need to incorporate
two
> more URL's because they also legitimate. I have learned basics in
PASCAL,
> Perl, BASH, C++, Visual Basic, HTML, PHP, and Java so I am not sure what
> coding to use. The statement that needs to be revised is:

> if ($ENV{HTTP_REFERER} eq
> "http://www.shadowcreek.org/messageboard/mbwrite.cgi")

> How can I make it have other possibilities for a match? My best guess
would
> be:

> if ($ENV{HTTP_REFERER} eq
> "http://www.shadowcreek.org/messageboard/mbwrite.cgi" ||
> "http://shadowcreek.org/messageboard/mbwrite.cgi")

One of the coolest features of perl is the hash (previously called an
'associative array'). This is a table which is subscripted by any value.

if you set up your program to include:

my %url_table =
 {"http://www.shadowcreek.org/messageboard/mbwrite.cgi" => 1,
  "http://shadowcreek.org/messageboard/mbwrite.cgi" => 1 };

then your  if statement can be:

if( defined $url_table{ $ENV{HTTP_REFERER} ) { ...
    ... ;

Quote:
}

The nice part is that the table can be of almost unbounded size
and perl manages the memory automagically.

--
Posted via CNET Help.com
http://www.help.com/



Tue, 01 Jul 2003 13:30:08 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Installing perl modules in win perl question

2. NT PERL Questions (Win-32 PERL Specific)

3. perl question

4. Command line Variables in html (perl Question)

5. newbie and perl question

6. perl question

7. perl question

8. Perl question

9. Finger/Ytalk/Perl Question

10. newbie TK/perl Question

11. Using C from Perl: Question(HELP!)

12. Perl Question.

 

 
Powered by phpBB® Forum Software