20 Nov 2008 07:56:19 UTC
- Distribution: Data-Microformat
- Module version: 0.04
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (192 / 501 / 0)
- KwaliteeBus factor: 0
- 79.30% Coverage
- License: perl_5
- Activity24 month
- Download (22.25KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionUSSJOIN Brendan Francis O'Connorand 1 contributors
- Brendan O'Connor
Data::Microformat::adr - A module to parse and create adrs
This documentation refers to Data::Microformat::adr version 0.03.
use Data::Microformat::adr; my $adr = Data::Microformat::adr->parse($a_web_page); print "The street address we found in this adr was:\n"; print $adr->street_address."\n"; # To create a new adr: my $new_adr = Data::Microformat::adr->new; $new_adr->street_address("548 4th St."); $new_adr->locality("San Francisco"); $new_adr->region("CA"); $new_adr->postal_code("94107"); $new_adr->country_name("USA"); print "Here's the new adr I've just made:\n"; print $new_adr->to_hcard."\n";
An adr is the address microformat used primarily in hCards. It exists as its own separate specification.
This module exists both to parse existing adrs from web pages, and to create new adrs so that they can be put onto the Internet.
To use it to parse an existing adr (or adrs), simply give it the content of the page containing them (there is no need to first eliminate extraneous content, as the module will handle that itself):
my $adr = Data::Microformat::adr->parse($content);
If you would like to get all the adrs on the webpage, simply ask using an array:
my @adrs = Data::Microformat::adr->parse($content);
To create a new adr, first create the new object:
my $adr = Data::Microformat::adr->new;
Then use the helper methods to add any data you would like. When you're ready to output the adr in the hCard HTML format, simply write
my $output = $adr->to_hcard;
And $output will be filled with an hCard representation, using <div> tags exclusively with the relevant class names.
The hCard class name for an address; to wit, "adr."
This is a method to list all the fields on an address that can hold exactly one value.
They are as follows:
The Post Office box, such as "P.O. Box 1234."
The street address, such as "1234 Main St."
The second line of the address, such as "Suite 1."
The postal code.
The name of the country, such as "U.S.A."
This is a method to list all the fields on an address that can hold multiple values.
They are as follows:
The type of address, such as "Home" or "Work."
Please report any bugs or feature requests to
bug-data-microformat at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Microformat. I will be notified,and then you'll automatically be notified of progress on your bug as I make changes.
<perl at ussjoin.com>
Copyright 2008, Six Apart Ltd. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
Module Install Instructions
To install Data::Microformat, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Data::Microformat
For more information on module installation, please visit the detailed CPAN module installation guide.