Perl Snippets
Perl, the Practical Extraction and Report Language, is designed to make the easy jobs easy, without making the hard jobs impossible
*.
We give several snippets of Perl, whose use can either be problematic or reveals interesting featues of the scripting language.
Domain Gate-Keeper
In order to prevent unauthorized use of cgi-bin perl scripts, a useful device is to restrict use to designated domain(s) by means of something like
The allowed domains, domain1, domain2, etc. are given in the
$allowed_domains string, each domain name being separated by a pipe. Entry is normally blocked also from bookmarks and desktop short cuts.
For example, the script below (Gatekeeper01.pl) gives a welcoming web page to vistors from allowed domains, but tells others to keep out.