diff options
| author | fukachan <fukachan> | 2003-11-26 11:00:32 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2003-11-26 11:00:32 +0000 |
| commit | 7ac20a697c3c8929f5cd48e71fe7f11a750b4a11 (patch) | |
| tree | 1bc43a411a0b0573cf958f19c2b824d4b38eeaf1 /fml/lib | |
| parent | b4b3a44abf1c849838fb9a401297ab467346228a (diff) | |
| download | fml8-7ac20a697c3c8929f5cd48e71fe7f11a750b4a11.tar.gz fml8-7ac20a697c3c8929f5cd48e71fe7f11a750b4a11.tar.bz2 fml8-7ac20a697c3c8929f5cd48e71fe7f11a750b4a11.zip | |
implement get_key_values_as_array_ref() to return key and all values
as ARRAY_REF.
Diffstat (limited to 'fml/lib')
| -rw-r--r-- | fml/lib/IO/Adapter/Array.pm | 13 | ||||
| -rw-r--r-- | fml/lib/IO/Adapter/DBI.pm | 16 | ||||
| -rw-r--r-- | fml/lib/IO/Adapter/File.pm | 20 |
3 files changed, 46 insertions, 3 deletions
diff --git a/fml/lib/IO/Adapter/Array.pm b/fml/lib/IO/Adapter/Array.pm index 39f90fe1..d9c7b58f 100644 --- a/fml/lib/IO/Adapter/Array.pm +++ b/fml/lib/IO/Adapter/Array.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: Array.pm,v 1.31 2003/05/26 12:28:05 fukachan Exp $ +# $FML: Array.pm,v 1.32 2003/08/23 04:35:43 fukachan Exp $ # package IO::Adapter::Array; @@ -127,6 +127,17 @@ return the next element of the array. sub getline { get_next_key(@_);} +# Descriptions: return (key, values, ... ) as ARRAY_REF +# Arguments: OBJ($self) HASH_REF($args) +# Side Effects: none +# Return Value: ARRAY_REF +sub get_key_values_as_array_ref +{ + my ($self) = @_; + my $x = $self->get_next_key(); + return [ $x ]; +} + # Descriptions: return the next element of the array # Arguments: OBJ($self) HASH_REF($args) # Side Effects: increment the counter in the object diff --git a/fml/lib/IO/Adapter/DBI.pm b/fml/lib/IO/Adapter/DBI.pm index 941d4691..566df4ef 100644 --- a/fml/lib/IO/Adapter/DBI.pm +++ b/fml/lib/IO/Adapter/DBI.pm @@ -3,7 +3,7 @@ # Copyright (C) 2000,2001,2002,2003 Ken'ichi Fukamachi # All rights reserved. # -# $FML: DBI.pm,v 1.27 2003/08/23 04:35:44 fukachan Exp $ +# $FML: DBI.pm,v 1.28 2003/08/24 14:09:25 fukachan Exp $ # package IO::Adapter::DBI; @@ -186,6 +186,17 @@ sub getline } +# Descriptions: return (key, values, ... ) as ARRAY_REF +# Arguments: OBJ($self) HASH_REF($args) +# Side Effects: none +# Return Value: ARRAY_REF +sub get_key_values_as_array_ref +{ + my ($self, $args) = @_; + $self->_get_data_from_cache($args, 'key,value'); +} + + # Descriptions: return the primary key in the table sequentially # Arguments: OBJ($self) HASH_REF($args) # Side Effects: none @@ -229,6 +240,9 @@ sub _get_data_from_cache shift @row; return \@row; } + elsif ($mode eq 'key,value') { + return \@row; + } elsif ($mode eq 'getline') { return join(" ", @row); } diff --git a/fml/lib/IO/Adapter/File.pm b/fml/lib/IO/Adapter/File.pm index 711ece3d..ed67e2e6 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.47 2003/08/23 04:35:44 fukachan Exp $ +# $FML: File.pm,v 1.48 2003/08/24 14:09:25 fukachan Exp $ # package IO::Adapter::File; @@ -221,6 +221,17 @@ sub get_next_key } +# Descriptions: return (key, values, ... ) as ARRAY_REF +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: ARRAY_REF +sub get_key_values_as_array_ref +{ + my ($self) = @_; + $self->_get_next_xxx('key,value_as_array_ref'); +} + + # Descriptions: get data and return key or value by $mode. # Arguments: OBJ($self) STR($mode) # Side Effects: none @@ -256,6 +267,13 @@ sub _get_next_xxx my (@buf) = split(/\s+/, $value); $buf = \@buf; } + elsif ($mode eq 'key,value_as_array_ref') { + $value =~ s/^\s*//; + $value =~ s/\s*$//; + my (@buf) = split(/\s+/, $value); + unshift(@buf, $key); + $buf = \@buf; + } $ec++; } return $buf; |
