summaryrefslogtreecommitdiff
path: root/fml/lib/IO/Adapter
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-08-26 03:39:58 +0000
committerfukachan <fukachan>2002-08-26 03:39:58 +0000
commit77cd7cc9a6c604fdb975af8222a1aa20fac20dc1 (patch)
treee687d41cf11cab2e70edeb08500945988cda68a7 /fml/lib/IO/Adapter
parentdf97ada514672787405d3d9d5ad71984a09f308f (diff)
downloadfml8-77cd7cc9a6c604fdb975af8222a1aa20fac20dc1.tar.gz
fml8-77cd7cc9a6c604fdb975af8222a1aa20fac20dc1.tar.bz2
fml8-77cd7cc9a6c604fdb975af8222a1aa20fac20dc1.zip
ensure rollback in calling get_value_*()
Diffstat (limited to 'fml/lib/IO/Adapter')
-rw-r--r--fml/lib/IO/Adapter/File.pm17
1 files changed, 14 insertions, 3 deletions
diff --git a/fml/lib/IO/Adapter/File.pm b/fml/lib/IO/Adapter/File.pm
index fa0eb07e..1c6f98c3 100644
--- a/fml/lib/IO/Adapter/File.pm
+++ b/fml/lib/IO/Adapter/File.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: File.pm,v 1.38 2002/08/19 15:19:46 fukachan Exp $
+# $FML: File.pm,v 1.39 2002/08/21 14:31:05 fukachan Exp $
#
package IO::Adapter::File;
@@ -307,11 +307,14 @@ sub get_value_as_array_ref
sub _get_value
{
my ($self, $key, $style) = @_;
- my $xkey = '';
- my $buf = '';
+ my $xkey = '';
+ my $buf = '';
+ my $curpos = $self->getpos();
my $fh = $self->{_fh};
if (defined $fh) {
+ $self->setpos(0);
+
LOOP:
while (<$fh>) {
($xkey, $buf) = split(/\s+/, $_, 2);
@@ -328,10 +331,18 @@ sub _get_value
$buf =~ s/^\s*//;
$buf =~ s/\s*$//;
my @a = split(/\s+/, $buf);
+
+ $self->setpos( $curpos );
return \@a;
}
+
}
+ else {
+ carp("cannot defined \$fh");
+ }
+
+ $self->setpos( $curpos );
return $buf;
}