Patch to make code use strict where appropriate and be generally
pleasing to the eye, and easy to understand.

  Casey West

-- 
Shooting yourself in the foot with SQL 
You cut your foot off, send it out to a service bureau and when it
returns, it has a hole in it but will no longer fit the attachment at
the end of your leg. 
diff -u perl-current.orig/pod/perldbmfilter.pod perl-current/pod/perldbmfilter.pod
--- perl-current.orig/pod/perldbmfilter.pod     Thu Sep 13 21:42:52 2001
+++ perl-current/pod/perldbmfilter.pod  Fri Sep 14 14:37:05 2001
@@ -4,12 +4,13 @@
 
 =head1 SYNOPSIS
 
-    $db = tie %hash, 'DBM', ...
+    my $db = tie my %hash, 'DBM', ...;
 
-    $old_filter = $db->filter_store_key  ( sub { ... } ) ;
-    $old_filter = $db->filter_store_value( sub { ... } ) ;
-    $old_filter = $db->filter_fetch_key  ( sub { ... } ) ;
-    $old_filter = $db->filter_fetch_value( sub { ... } ) ;
+    my $old_filter;
+    $old_filter = $db->filter_store_key  ( sub { ... } );
+    $old_filter = $db->filter_store_value( sub { ... } );
+    $old_filter = $db->filter_fetch_key  ( sub { ... } );
+    $old_filter = $db->filter_fetch_value( sub { ... } );
 
 =head1 DESCRIPTION
 
@@ -85,30 +86,30 @@
 sure you have already guessed, this is a problem that DBM Filters can
 fix very easily.
 
-    use strict ;
-    use warnings ;
-    use SDBM_File ;
-    use Fcntl ;
-
-    my %hash ;
-    my $filename = "/tmp/filt" ;
-    unlink $filename ;
+    use strict;
+    use warnings;
+    use SDBM_File;
+    use Fcntl;
+
+    my %hash;
+    my $filename = '/tmp/filt';
+    unlink $filename;
 
     my $db = tie(%hash, 'SDBM_File', $filename, O_RDWR|O_CREAT, 0640)
-      or die "Cannot open $filename: $!\n" ;
+      or die "Cannot open $filename: $!\n";
 
     # Install DBM Filters
-    $db->filter_fetch_key  ( sub { s/\0$//    } ) ;
-    $db->filter_store_key  ( sub { $_ .= "\0" } ) ;
+    $db->filter_fetch_key  ( sub { s/\0$//    } );
+    $db->filter_store_key  ( sub { $_ .= "\0" } );
     $db->filter_fetch_value( 
-        sub { no warnings 'uninitialized' ;s/\0$// } ) ;
-    $db->filter_store_value( sub { $_ .= "\0" } ) ;
+        sub { no warnings 'uninitialized'; s/\0$// } );
+    $db->filter_store_value( sub { $_ .= "\0" } );
 
-    $hash{"abc"} = "def" ;
-    my $a = $hash{"ABC"} ;
+    $hash{abc} = 'def';
+    my $a = $hash{ABC};
     # ...
-    undef $db ;
-    untie %hash ;
+    undef $db;
+    untie %hash;
 
 The code above uses SDBM_File, but it will work with any of the DBM
 modules.
@@ -124,7 +125,7 @@
 a DBM database it always writes the key and value as strings. So when
 you use this:
 
-    $hash{12345} = "something" ;
+    $hash{12345} = 'something';
 
 the key 12345 will get stored in the DBM database as the 5 byte string
 "12345". If you actually want the key to be stored in the DBM database
@@ -133,23 +134,23 @@
 
 Here is a DBM Filter that does it:
 
-    use strict ;
-    use warnings ;
-    use DB_File ;
-    my %hash ;
-    my $filename = "/tmp/filt" ;
-    unlink $filename ;
+    use strict;
+    use warnings;
+    use DB_File;
+    my %hash;
+    my $filename = '/tmp/filt';
+    unlink $filename;
 
 
     my $db = tie %hash, 'DB_File', $filename, O_CREAT|O_RDWR, 0666, $DB_HASH 
-      or die "Cannot open $filename: $!\n" ;
+      or die "Cannot open $filename: $!\n";
 
-    $db->filter_fetch_key  ( sub { $_ = unpack("i", $_) } ) ;
-    $db->filter_store_key  ( sub { $_ = pack ("i", $_) } ) ;
-    $hash{123} = "def" ;
+    $db->filter_fetch_key  ( sub { $_ = unpack('i', $_) } );
+    $db->filter_store_key  ( sub { $_ = pack  ('i', $_) } );
+    $hash{123} = 'def';
     # ...
-    undef $db ;
-    untie %hash ;
+    undef $db;
+    untie %hash;
 
 The code above uses DB_File, but again it will work with any of the
 DBM modules.

Reply via email to