NAME

WWW::Fuel::US::Prices - Perl Module to get the gas prices around a particular zip code in the US

VERSION

This document describes WWW::Fuel::US::Prices version 0.0.1

SYNOPSIS

    use WWW::Fuel::US::Prices;
    my $gasPrices = new WWW::Fuel::US::Prices("75023"); #or any other zip code
	

DESCRIPTION

The module gets gas prices for a given zip code in the US. It gets its data by scraping msn autos webpage.

It retrieves a bunch of gas stations around the particular zip code, and for each gas station, it retrives the following data

Station name: station_name

Station address: station_address

Unleaded price: unleaded_price

Unleaded date: unleaded_date

Plus price: plus_price

Plus date: plus_date

Premium price: premium_price

Premium_date: premium_date

Diesel price: diesel_price

Diesel date: diesel_date

EXAMPLE

The usage is as follows

    use WWW::Fuel::US::Prices;
    my $gasPrices = new WWW::Fuel::US::Prices("75023"); #or any other zip code
    
    my @gas_stations = @{$gasPrices->get_stations};
    
    foreach(@gas_stations)
    {
        print   "Station name: " . $_->{station_name} . "\n" .
	"Station address: " . $_->{station_address} . "\n" .
	"Unleaded price: " . $_->{unleaded_price} . "\n" .
	"Unleaded date: " . $_->{unleaded_date} . "\n" .
	"Plus price: " . $_->{plus_price} . "\n" .
	"Plus date: " . $_->{plus_date} . "\n" .
	"Premium price: " . $_->{premium_price} . "\n" .
	"Premium_date: " . $_->{premium_date} . "\n" .
	"Diesel price: " . $_->{diesel_price} . "\n" .
	"Diesel date: " . $_->{diesel_date} . "\n\n";
    }

    my $cheapest_unleaded = $gasPrices->get_cheapest_station("unleaded");
    print "The cheapest unleaded grade gas near 75023 is " . $cheapest_unleaded->{station_name} . 
        " at " . $cheapest_unleaded->{station_address} . 
        ' for $' . $cheapest_unleaded->{unleaded_price} . "/gallon.";
	

INTERFACE

new

Creates a new WWW::Fuel::US::Prices object, and fetches data.

my $gasPrices = new WWW::Fuel::US::Prices("75023");

get_cheapest_station

Gets the gas stations with the cheapest price for a give type of gas

my $unleaded_station = $gasPrices->get_cheapest_station("unleaded"); my $diesel_station = $gasPrices->get_cheapest_station("diesel");

The only valid values for the parameter are "unleaded", "plus", "premium" and "diesel".

get_most_expensive_station

Works the same way as get_cheapest_station, but returns the station with the most expensive fuel for the given type.

get_stations

Returns an array of Gas stations around that zip code for which gas price info is present

my @gas_stations = @{$gasPrices->get_stations}; foreach(@gas_stations) { # ... }

is_greater

Subroutine used internally (need a better way to do this)

is_less

Same as is_greater

CONFIGURATION AND ENVIRONMENT

WWW::Fuel::US::Prices requires no configuration files or environment variables.

DEPENDENCIES

WWW::Fuel::US::Prices uses HTTP::Lite.

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to bug-www-fuel-us-prices@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

Ashish Kasturia <ashoooo@cpan.org>

LICENCE AND COPYRIGHT

Copyright (c) 2007, Ashish Kasturia <ashoooo@cpan.org>. All rights reserved.

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

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.