[ale] OT: perl dbm files?
Mike Fletcher
fletch at phydeaux.org
Fri Nov 19 10:53:15 EST 1999
01: foreach $Directory (@DoDirs) {
02: print " \$Directory :$Directory:\n" if ($Verbose eq "T");
03: unlink($DB);
04: umask(0377);
05: $DB="$Directory"."/"."$DBFile";
06: print " \$DB :$DB:\n" if ($Verbose eq "T");
07: tie(%KnownGood, 'DB_File', $DB) or die "Can't open DB_File $DB : $!\n";
08:
09: %KnownGood=&GetDirStats($Directory);
10:
11: print " Print File:\n" if ($Verbose eq "T");
12: foreach $Key (keys %KnownGood) {
13: print " \$KnownGood{$Key} :$KnownGood{$Key}:\n" if ($Verbose eq "T");
14: }
15:
16: untie(%KnownGood);
17: }
----------------------------------------------------
Robert> The print of the HASH looks good, but it doesn't even
Robert> create $DB and it doesn't die. Thoughts?
It does create $DB, but since on line 3 you have `unlink($DB)'
before you set $DB on line 5 you're removing the previous loop's file
each time through. Chances are that you've got one file left in
whatever directory happens to be the last in @DoDirs.
So swap line 5 up before line 3 (and you could rewrite it a
bit more clearly as `$DB = "$Directory/$DBFile";' in the process :).
And the `if ($Verbose eq "T")' could be written more
succinctly as `if $Verbose' (assuming you start off with setting
`$Verbose = undef;' in the case you don't want verbose output).
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org | Vincent, you should cease askin' \ o.O'
678 443-6239(w) | scary questions." -- Jules =(___)=
| U
More information about the Ale
mailing list