Weather::NHC::TropicalCyclone - Provides a convenient interface to NHC's Tropical Cyclone JSON format.


   use strict;
   use warnings;
   use Weather::NHC::TropicalCyclone ();
   my $nhc = Weather::NHC::TropicalCyclone->new;
   my $storms_ref = $nhc->active_storms;
   foreach my $storm (@$storms_ref) {
     print $storm->name . qq{\n};
     my ($text, $advNum, $local_file) = $storm->fetch_publicAdvisory($storm->id.q{.fst});
     print qq{$local_file saved for Advisory $advNum\n};
     print $text;



Constructor - doesn't do much, but provide a convenient instance for the other provided methods described below.


Makes an HTTP request to $Weather::NHC::TropicalCyclone::DEFAULT_URL to get the JSON provided by the NHC describing the current set of active storms.

If the JSON is malformed or otherwise can't be parsed, fetch will throw an exception.

Fetch will time out after $Weather::NHC::TropicalCyclone::DEFAULT_TIMEOUT by throwing an exception. In order to disable the alarm, call fetch with a parameter of 0:


Provides an array reference of Weather::NHC::TropicalCyclone::Storm instances, one for each active storm. If there are no storms, the array reference returned is empty (not undef).

Most of the useful functionality related to this JSON data is available through the methods provided by the Weather::NHC::TropicalCyclone::Storm instances returned by this method.


There are no parameters for this method.

Returns a list of storm ids (e.g., ep082019) that are listed in the storm cache.


This methods requires a single parameter, and it should be of the form of a storm id, e.g., 'al202020', 'cp062006', etc. If the storm exists in the cache, it returns an instance of Weather::NHC::TropicalCyclone::Storm. If there is no matching storm id, then it returns undef.

Provides a constant time look up of storms stored in the internal storm cache that is updated whenever fetch is called.

Auxillary RSS Fetch Methods

The following methods are provided to fetch the raw text of some of the RSS feeds available at

   my $nhc         = Weather::NHC::TropicalStorm->new;
   my $at_rss_text = $nhc->fetch_rss_atlantic; 
   my $ep_rss_text = $nhc->fetch_rss_east_pacific; 
   my $cp_rss_text = $nhc->fetch_rss_central_pacific;

Note: This module doesn't provide facilities for converting this RSS into a Perl data structure. For this, use a module like XML::RSS.

All methods provide return the text of the RSS. If an optional parameter is passed to the call that specifies a local file, the contents retrieved is saved to this file.


Fetches RSS available at Internally, this URL is defined with the package variable, $DEFAULT_RSS_ATLANTIC.


Fetches RSS available at Internally, this URL is defined with the package variable, $DEFAULT_RSS_EAST_PACIFIC.


Fetches RSS available at Internally, this URL is defined with the package variable, $DEFAULT_RSS_CENTRAL_PACIFIC.

Internal Methods


This methods is used by fetch to update the internal cache when a new JSON file is processed. The internal cache facilitates constant time look up of storms using the get_storm_by_id. This internal cache is also the source of the storm ids returned by get_storm_ids.


This module is distributed under the same terms as Perl itself.