diff options
| author | fukachan <fukachan> | 2004-01-24 09:03:55 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-01-24 09:03:55 +0000 |
| commit | ff05d890ce1e70329fff09e207acd4d11740090f (patch) | |
| tree | a7d4024ed2867e73e5f94b0b696fa4b1633785fa /fml/lib/IO/Adapter/File.pm | |
| parent | 22441065efdc239bc5533152f7fc2a61623916c7 (diff) | |
| download | fml8-ff05d890ce1e70329fff09e207acd4d11740090f.tar.gz fml8-ff05d890ce1e70329fff09e207acd4d11740090f.tar.bz2 fml8-ff05d890ce1e70329fff09e207acd4d11740090f.zip | |
overhaul from FNF point view.
o fix comments.
o fix loop label name.
o more correct initialization if could.
o use //o;
Diffstat (limited to 'fml/lib/IO/Adapter/File.pm')
| -rw-r--r-- | fml/lib/IO/Adapter/File.pm | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/fml/lib/IO/Adapter/File.pm b/fml/lib/IO/Adapter/File.pm index b1980b34..587b413e 100644 --- a/fml/lib/IO/Adapter/File.pm +++ b/fml/lib/IO/Adapter/File.pm @@ -1,10 +1,10 @@ #-*- perl -*- # -# Copyright (C) 2001,2002,2003 Ken'ichi Fukamachi +# Copyright (C) 2001,2002,2003,2004 Ken'ichi Fukamachi # 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.49 2003/11/26 11:00:32 fukachan Exp $ +# $FML: File.pm,v 1.50 2003/11/27 04:26:09 fukachan Exp $ # package IO::Adapter::File; @@ -82,7 +82,7 @@ C<flag> is the mode of open(). =cut -# Descriptions: open map +# Descriptions: open map. # Arguments: OBJ($self) HASH_REF($args) # Side Effects: file opened # Return Value: HANDLE @@ -101,7 +101,7 @@ sub open } -# Descriptions: open file in "read only" mode +# Descriptions: open file in "read only" mode. # Arguments: OBJ($self) HASH_REF($args) # Side Effects: file is opened for read # Return Value: HANDLE @@ -124,7 +124,7 @@ sub _read_open } -# Descriptions: open file in "read/write" mode +# Descriptions: open file in "read/write" mode. # Arguments: OBJ($self) HASH_REF($args) # Side Effects: file is opened for read # Return Value: HANDLE @@ -149,14 +149,14 @@ create a file if not exists. =cut -# Descriptions: touch (create a file if needed) +# Descriptions: touch (create a file if needed). # Arguments: OBJ($self) # Side Effects: create a file # Return Value: same as close() sub touch { my ($self) = @_; - my $file = $self->{_file}; + my $file = $self->{_file}; use IO::File; my $fh = new IO::File; @@ -192,15 +192,15 @@ It is the same as usual getline() call for a file. =cut -# Descriptions: get string for new line +# Descriptions: get string for new line. # Arguments: OBJ($self) # Side Effects: none # Return Value: STR sub getline { my ($self) = @_; - my $fh = $self->{_fh}; + my $fh = $self->{_fh}; if (defined $fh) { $fh->getline; } @@ -210,7 +210,7 @@ sub getline } -# Descriptions: return the next key +# Descriptions: return the next key. # Arguments: OBJ($self) # Side Effects: none # Return Value: STR @@ -221,7 +221,7 @@ sub get_next_key } -# Descriptions: return (key, values, ... ) as ARRAY_REF +# Descriptions: return (key, values, ... ) as ARRAY_REF. # Arguments: OBJ($self) # Side Effects: none # Return Value: ARRAY_REF @@ -244,13 +244,13 @@ sub _get_next_xxx my $fh = $self->{_fh}; if (defined $fh) { - INPUT: + LINE: while ($buf = <$fh>) { $c++; # for benchmark (debug) - next INPUT if not defined $buf; - next INPUT if $buf =~ /^\s*$/o; - next INPUT if $buf =~ /^\#/o; - last INPUT; + next LINE if not defined $buf; + next LINE if $buf =~ /^\s*$/o; + next LINE if $buf =~ /^\#/o; + last LINE; } if (defined $buf) { @@ -273,8 +273,8 @@ sub _get_next_xxx if (defined $key && $key) { if (defined $value && $value) { - $value =~ s/^\s*//; - $value =~ s/\s*$//; + $value =~ s/^\s*//o; + $value =~ s/\s*$//o; (@buf) = split(/\s+/, $value); } unshift(@buf, $key); @@ -304,25 +304,27 @@ set the position in the opened file. =cut -# Descriptions: return current postion in file descriptor +# Descriptions: return current postion in file descriptor. # Arguments: OBJ($self) # Side Effects: none # Return Value: NUM sub getpos { my ($self) = @_; + my $fh = $self->{_fh}; defined $fh ? tell($fh) : undef; } -# Descriptions: reset postion in file descriptor +# Descriptions: reset postion in file descriptor. # Arguments: OBJ($self) NUM($pos) # Side Effects: none # Return Value: NUM sub setpos { my ($self, $pos) = @_; + my $fh = $self->{_fh}; seek($fh, $pos, 0); } @@ -339,25 +341,27 @@ close the opended file. =cut -# Descriptions: EOF or not +# Descriptions: check if EOF or not. # Arguments: OBJ($self) # Side Effects: none # Return Value: same as eof() sub eof { my ($self) = @_; + my $fh = $self->{_fh}; $fh->eof if defined $fh; } -# Descriptions: close map +# Descriptions: close map. # Arguments: OBJ($self) # Side Effects: none # Return Value: same as close() sub close { my ($self) = @_; + $self->{_fh}->close if defined $self->{_fh}; } @@ -369,7 +373,7 @@ add (append) $address to this map. =cut -# Descriptions: add $addr into map +# Descriptions: add $addr into map. # Arguments: OBJ($self) STR($addr) VARARGS($argv) # Side Effects: update map # Return Value: same as close() @@ -426,7 +430,7 @@ delete lines with key $key from this map. =cut -# Descriptions: delete address(es) matching $reexp from map +# Descriptions: delete address(es) matching $reexp from map. # Arguments: OBJ($self) STR($key) # Side Effects: update map # Return Value: same as close() @@ -471,7 +475,7 @@ Ken'ichi Fukamachi =head1 COPYRIGHT -Copyright (C) 2001,2002,2003 Ken'ichi Fukamachi +Copyright (C) 2001,2002,2003,2004 Ken'ichi Fukamachi All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
