summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-08-07 14:36:37 +0000
committerfukachan <fukachan>2002-08-07 14:36:37 +0000
commit992ae6a64e5a2317f87d81a423e50efde3ec5505 (patch)
tree25317387fa587a69bc30986a22b8b918c8e9132a /fml
parentea49708c73714562f4f2b5e345bae2ce26ea4ed7 (diff)
downloadfml8-992ae6a64e5a2317f87d81a423e50efde3ec5505.tar.gz
fml8-992ae6a64e5a2317f87d81a423e50efde3ec5505.tar.bz2
fml8-992ae6a64e5a2317f87d81a423e50efde3ec5505.zip
check the file existence
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/Tie/JournaledFile.pm41
1 files changed, 23 insertions, 18 deletions
diff --git a/fml/lib/Tie/JournaledFile.pm b/fml/lib/Tie/JournaledFile.pm
index 1d9bda27..68631f14 100644
--- a/fml/lib/Tie/JournaledFile.pm
+++ b/fml/lib/Tie/JournaledFile.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: JournaledFile.pm,v 1.19 2002/08/03 10:30:44 fukachan Exp $
+# $FML: JournaledFile.pm,v 1.20 2002/08/03 13:13:29 fukachan Exp $
#
package Tie::JournaledFile;
@@ -221,29 +221,34 @@ sub get_all_values_as_hash_ref
my $fh = new IO::File;
$self->{ _fh } = $fh;
- $fh->open($self->{ '_file' }, "r");
+ if (-f $self->{ '_file' }) {
+ $fh->open($self->{ '_file' }, "r");
- if (defined $fh) {
- my ($a, $k, $v);
- while (<$fh>) {
- chomp;
+ if (defined $fh) {
+ my ($a, $k, $v);
+ while (<$fh>) {
+ chomp;
- ($k, $v) = split(/\s+/, $_, 2);
+ ($k, $v) = split(/\s+/, $_, 2);
- if (defined $hash->{ $k }) {
- $a = $hash->{ $k };
- }
- else {
- $a = [];
- }
+ if (defined $hash->{ $k }) {
+ $a = $hash->{ $k };
+ }
+ else {
+ $a = [];
+ }
- push(@$a, $v);
- $hash->{ $k } = $a;
+ push(@$a, $v);
+ $hash->{ $k } = $a;
+ }
+ $fh->close();
}
- $fh->close();
- }
- return $hash;
+ return $hash;
+ }
+ else {
+ return undef;
+ }
}