NAME

Tie::FieldVals::Join::Row - a hash tie for two rows of Tie::FieldVals data

VERSION

This describes version 0.20 of Tie::FieldVals::Join::Row.

SYNOPSIS

    use Tie::FieldVals::Row;
    use Tie::FieldVals::Join::Row;

    my %person;

    my @keys = qw(Forename Surname DateOfBirth Gender);

    tie %person, 'Tie::FieldVals::Row', fields=>\@keys;

    my %thing;

    my @keys2 = qw(Forename House Car TV);

    tie %thing, 'Tie::FieldVals::Row', fields=>\@keys2;

    my %person_thing;
    tie %person_thing, 'Tie::FieldVals::Join::Row,
	rows=>[\%person, \%thing];

DESCRIPTION

This is a Tie object to map two Tie::FieldVals::Row hashes to one hash.

OBJECT METHODS

set_from_strings

Set the hash data from some enhanced Field:Value data strings.

$hash_obj->set_from_strings([$str1, $str2]);

$hash_obj->set_from_strings([$str1, $str2], override_keys=>1);

get_as_strings

Returns the hash data as an array of Field:Value strings.

my @str_array = $hash_obj->get_as_string();

field_count

my $cnt = $hash_obj->field_count($field_name);

Return the number of different field values for the given field in the given record. A multi-valued field will give a count greater than 1.

If there is no value defined for the given field, then returns zero.

set_fields_as_vars

    $hash_obj->set_fields_as_vars($package_name);

    $hash_obj->set_fields_as_vars($package_name,
	field_ind=>$field_ind,
	reorder_value_fields=>{Author=>','});

Sets the data of the hash as variables with the same name as the field name; multi-valued fields have arrays of the field name.

These are set in the given package.

See "set_fields_as_vars" in Tie::FieldVals::Row for more information.

match

    $hash_obj->match(Author=>qr/Li.a/,
	    Universe=>'Buffy',
	    Year=>'> 2001')

Checks if this row matches the hash. The hash is in the form of Field => value pairs, where the value can be a plain value a comparison (< > = eq ne ...) or a regular expression.

If the plain value or the comparison starts with '!' then the sense of the comparison is reversed.

Returns: 1 if matches all conditions, 0 if fails

match_any

$hash_obj->match_any($match_str);

Checks any field in this row matches the string.

Returns: 1 if any field matches the string, 0 if fails

TIE-HASH METHODS

TIEHASH

Create a new instance of the object as tied to a hash.

    tie %person, 'Tie::FieldVals::Row', fields=>\@keys;
    tie %thing, 'Tie::FieldVals::Row', fields=>\@keys2;

    my %person_thing;
    tie %person_thing, 'Tie::FieldVals::Join::Row,
	rows=>[\%person, \%thing];

FETCH

Get a key=>value from the hash

$val = $hash{$key}
$val = $hash{{$key=>0}}; # 0th element of $key field
$val = $hash{[$key,2]}; # 3rd element of $key field
$val = $hash{{$key=>undef}}; # whole key field as array ref

STORE

Add a key=>value to the hash

$hash{$key} = $val;
$hash{{$key=>0}} = $val; # 0th element of $key field
$hash{[$key,2]} = $val; # 3rd element of $key field

DELETE

Remove a key=>value from the hash

CLEAR

Remove all the data from the hash.

EXISTS

Does this key exist?

FIRSTKEY

Get the first key of this hash.

NEXTKEY

Get the next key of this hash.

PRIVATE METHODS

For developer reference only.

debug

Set debugging on.

whowasi

For debugging: say who called this

is_matched

is_matched($str,$re)

Check if the string matches

REQUIRES

Test::More
Carp

SEE ALSO

perl(1). Tie::FieldVals Tie::FieldVals::Join

BUGS

Please report any bugs or feature requests to the author.

AUTHOR

Kathryn Andersen (RUBYKAT)
perlkat AT katspace dot com
http://www.katspace.com

COPYRIGHT AND LICENCE

Copyright (c) 2004 by Kathryn Andersen

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.