You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@httpd.apache.org by Joshua Slive <jo...@slive.ca> on 2002/02/02 03:50:18 UTC

perl guru: mod_rewrite example

Does some kind perl guru out there want to look at 
http://bugs.apache.org/index.cgi/full/9686
see if this person makes sense and suggest an alternative.

Thanks.

Joshua.

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


RE: perl guru: mod_rewrite example

Posted by Joshua Slive <jo...@slive.ca>.
> From: Patrik Grip-Jansson [mailto:patrikj@gnulix.org]

> He's right, and the proposed fix looks good. However, since we're redoing
> the script, we might as well fix some other stuff...

OK.  I committed your version.  Thanks.

Joshua.


---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Re: perl guru: mod_rewrite example

Posted by Patrik Grip-Jansson <pa...@gnulix.org>.
On Fri, 1 Feb 2002, Joshua Slive wrote:

> Does some kind perl guru out there want to look at 
> http://bugs.apache.org/index.cgi/full/9686
> see if this person makes sense and suggest an alternative.

He's right, and the proposed fix looks good. However, since we're redoing 
the script, we might as well fix some other stuff...

The following script adds some error checking and allows comments on the 
data rows (so that it works with the example "map.txt"). One could remove 
the parenthesis in the if:s, but I guess this isn't a round of golf :-) 
Anyhow, here is my proposal for a new txt2dbm:

#!/path/to/bin/perl
##
##  txt2dbm -- convert txt map to dbm format
##

use NDBM_File;
use Fcntl;

($txtmap, $dbmmap) = @ARGV;

open(TXT, "<$txtmap") or die "Couldn't open $txtmap!\n";
tie (%DB, 'NDBM_File', $dbmmap,O_RDWR|O_TRUNC|O_CREAT, 0644) or die "Couldn't create $dbmmap!\n";

while (<TXT>) {
  next if (/^\s*#/ or /^\s*$/);
  $DB{$1} = $2 if (/^\s*(\S+)\s+(\S+)/);
}

untie %DB;
close(TXT);

-- 
.---------------------.
| Patrik Grip-Jansson |
| Ringen 4B           |    .--------------------.
| 78444 Borlänge   .--'----' http://gnulix.com/ `---------.
| Sweden           |  All views and opinions are my own,  |
`------------------| PH:+46(0)24382823 PW:+46(0)707354360 |
                   `--------------------------------------'


---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org