Geo::Postcodes::Selection

Geo::Postcodes::Selection contains a tutorial about how to use the selection procedure/method of the Geo::Postcodes::* modules.
Download

Geo::Postcodes::Selection Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Arne Sommer
  • Publisher web site:
  • http://search.cpan.org/~arne/Geo-Postcodes-0.32/lib/Geo/Postcodes/Ajax.pod

Geo::Postcodes::Selection Tags


Geo::Postcodes::Selection Description

Geo::Postcodes::Selection contains a tutorial about how to use the selection procedure/method of the Geo::Postcodes::* modules. SELECTIONselection procedure my @postcodes = Geo::Postcodes::U2::selection($field => $value);This simple form will give a list of postcodes matching the specified field and value. Substitute 'U2' by a valid country subclass. The fields can be anyone given by the Geo::Postcodes::U2::get_fields() call, and the value either a literal text or a regular expression. The resulting list of postcodes is sorted. An empty list is also returned if one ore more of the arguments are invalid, but this can be checked by using the verify_selectionlist procedure described later on.It is possible to specify more than one field/value pair, but then the mode should be given (but it will default to 'and' otherwise). Use as many field/value-pairs as required. The mode can be specified initially, between the field/value pairs, or not at all.The following examples are equivalent: Geo::Postcodes::U2::selection('and', $field => $value, $field2 => $value2); Geo::Postcodes::U2::selection( $field => $value, 'and', $field2 => $value2); Geo::Postcodes::U2::selection( $field => $value, $field2 => $value2);The field/value pairs are evaluated in the specified order, and the modes can be mixed freely: Geo::Postcodes::U2::selection($field1 => $value1, 'and', $field2 => $value2, 'or', $field3 => $value3, 'or not', $field3 => $value3, 'and not, $field4 => $value4, 'xor', $field5 => $value5);ModesThe modes (except 'all', 'none', 'not', and 'one') can be summarised by the following truth table: A B | and and nand nand nor nor or or xnor xnor xor xor | not not not not not not -----+---------------------------------------------------- 0 0 | 0 0 1 1 1 0 0 1 1 0 0 1 0 1 | 0 0 1 1 0 1 1 0 0 1 1 0 1 0 | 0 1 1 0 0 0 1 1 0 1 1 0 1 1 | 1 0 0 1 0 0 1 1 1 0 0 1Using 'not' after the mode negates the second argument, and the 'nxxx' variants negate the result.allAll the postcodes. This mode is only legal as the first argument, and any additional arguments are silently ignored. my @postcodes = Geo::Postcodes::U2::selection('all');This will return all the postcodes, as a sorted list.This is the same as sort get_postcodes(). The object oriented version (see below for syntax) will return a postcode object for each postcode, and may be handy in some circumstances - if time and memory usage is of no concern. Otherwise create the postcode objects only when needed, inside a foreach-loop on the procedure version - or use selection_loop.andThe postcode is included in the result if it is included in all the expressions. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'and', $field2 => $value2);Return postcodes matching all the field/value pairs.The computation will work faster if the field/value pairs are given with the one with the most matches first, and the one with the least matches last. given firstand notThe postcode is included in the result if it is included in the first expression, but not the second one. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'and not', $field2 => $value2);Return the postcodes not matching any of the field/value pairs. (This is the same as all - or, on sets of postcodes.)nandThe postcode is included in the result if it is included in none or only one of the expressions. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'nand', $field2 => $value2);nand notThe postcode is included in the result unless it is included in the first but not the second expression only. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'nand not', $field2 => $value2);norThe postcode is included in the result if it is included in none of the expressions. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'nor', $field2 => $value2);nor notThe postcode is included in the result if it is included in the second expression only. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'nor not', $field2 => $value2);noneThis will return absolutely nothing.This mode is only legal as the first argument, and any additional arguments are silentliy ignored. my @postcodes = Geo::Postcodes::U2::selection('none');This will return undef.notThis mode can be used initially (as the first argument) to negate the first field/value pair. It is also possible to use 'and not' or any other 'xxx not'-mode initially.Note that 'not' is not a valid mode, and it will default to 'and' for any additional field/value pairs if no mode is given.The following examples are equivalent: Geo::Postcodes::U2::selection('not', $field => $value, 'and', $field2 => $value2); Geo::Postcodes::U2::selection('not', $field => $value, $field2 => $value2); Geo::Postcodes::U2::selection('or not', $field => $value, 'and', $field2 => $value2); Geo::Postcodes::U2::selection('and not', $field => $value, 'and', $field2 => $value2); Geo::Postcodes::U2::selection('and not', $field => $value, $field2 => $value2);The following examples are equivalent: Geo::Postcodes::U2::selection('or not', $field => $value, $field2 => $value2); Geo::Postcodes::U2::selection('not', $field => $value, 'or not', $field2 => $value2);oneThis mode can be used initially to limit the returned list of postcodes to just one (or zero). The returned postcode is chosen randomly from the result list. Geo::Postcodes::U2::selection('one', $field => $value);It can also be used on its own, just to get a random postcode. Geo::Postcodes::U2::selection('one');orThe postcode is included in the result if it is included in at least one of the expressions. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'or', $field2 => $value2);Return postcodes matching one or more of the field/value pairs.The computation will work faster if the field/value pairs are given with the one with the least matches first, and the one with the most matches last. given firstor notThe postcode is included in the result unless it is included in the second expression only. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'or not', $field2 => $value2);It is also possible to achieved this by using 'or' and a reversed regular expression.xnorThe postcode is included in the result if it is included in none or both expressions. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'xnor', $field2 => $value2);xnor notThe postcode is included in the result if it is included in only one of the expressions. This mode is the same as 'xor'. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'xnor not', $field2 => $value2);xor (exlusive or)The postcode is included in the result if it is included in only one of the expressions. my @postcodes = Geo::Postcodes::U2::selection( $field1 => $value1, 'xor', $field2 => $value2);xor notThe postcode is included in the result if it is included in both or none of the expressions.Requirements:· Perl Requirements: · Perl


Geo::Postcodes::Selection Related Software