From: Joshua Slive Date: Wed, 6 Feb 2002 18:59:20 +0000 (+0000) Subject: Improve example perl script. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91071567eded064c8349c87a763aea4b9cbcb7d8;p=apache Improve example perl script. I'm no perl expert, so additional reviewing eyes may be needed. PR: 9686 Submitted by: rodrigo campos , Patrik Grip-Jansson git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93305 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_rewrite.html b/docs/manual/mod/mod_rewrite.html index 30e298ff5d..66d2f273ef 100644 --- a/docs/manual/mod/mod_rewrite.html +++ b/docs/manual/mod/mod_rewrite.html @@ -1,5 +1,5 @@ + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> @@ -731,15 +731,21 @@ RewriteMap servers rnd:/path/to/file/map.txt ## txt2dbm -- convert txt map to dbm format ## +use NDBM_File; +use Fcntl; + ($txtmap, $dbmmap) = @ARGV; -open(TXT, "<$txtmap"); -dbmopen(%DB, $dbmmap, 0644); + +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 (m|^s*#.*| or m|^s*$|); - $DB{$1} = $2 if (m|^\s*(\S+)\s+(\S+)$|); + next if (/^\s*#/ or /^\s*$/); + $DB{$1} = $2 if (/^\s*(\S+)\s+(\S+)/); } -dbmclose(%DB); -close(TXT) + +untie %DB; +close(TXT);