Free Programming Books
Free download ebooks on computer and programming | |||
Free Ebook "Beginning Perl Web Development: From Novice to Professional" Sample Chapter
Beginning Perl Web Development
Download chapter
Free downloadable Chapter 8: Perl and RSS Beginning Perl Web Development: From Novice to Professional introduces you to the world of Perl Internet application development. This book tackles all areas crucial to developing your first web applications and includes a powerful combination of real-world examples coupled with advice. Topics range from serving and consuming RSS feeds, to monitoring Internet servers, to interfacing with e-mail. You'll learn how to use Perl with ancillary packages like Mason and Nagios. Though not version specific, this book is an ideal read if you have had some grounding in Perl basics and now want to move into the world of web application development. Author Steve Suehring emphasizes the security implications of Perl, drawing on years of experience teaching readers how to "think safe," avoid common pitfalls, and produce well-planned, secure code. Perl and RSSRSS (an abbreviation for Rich Site Summary or RDF Site Summary) is used to syndicate content from a web site. RSS is helpful for gathering headlines and other news-related items from web sites or getting recent changes to a web page. It's common for an end user to use news aggregation software to consume RSS feeds. Web browsers such as Mozilla Firefox also enable RSS feeds to be used as bookmarks. Various Perl modules handle RSS feeds. Some of the modules, such as XML::RSS, are general and designed to work with most any RSS feed; others are specific to a particular site's RSS feed. For example, XML::RSS::Headline::PerlJobs gets the headlines from jobs.perl.org, and XML::RSS::Headline::Fark gets headlines from the popular Fark web site. This chapter looks at RSS from a Perl perspective. Specifically, you'll see how to consume and create RSS feeds using the XML::RSS module. RSS: Versioning FunAt the time of this writing, there are four versions of the RSS protocol: 0.90, 0.91, 1.0, and 2.0. Some aggregation software works with only certain versions of the protocol. The aggregators may support a limited subset of a newer version, or they may not support a newer version at all. Similarly, the Perl modules may or may not support every version of the RSS protocol. Some RSS modules handle the versions well, simply ignoring things that they don't implement, while others don't fail so gracefully. The best method for determining whether the module you're using works with a particular version of RSS is to read the documentation for that particular module. For those not familiar with RSS, you can pull up an RSS feed through your web browser. You can point your browser at the example used throughout the chapter: http://www.spc.noaa.gov/ products/spcwwrss.xml. Reading RSS with XML::RSSThe previous chapter described how to consume a SOAP-based web service from the United States National Weather Service. The National Weather Service has a division called the Storm Prediction Center (SPC), which handles the forecasting of severe or extreme weather events for the United States. The SPC home page is http://www.spc.noaa.gov/. Among the many products offered for current conditions and forecasting is an RSS feed of mesoscale discussions, convective outlooks, and watches. Here, you'll see how to consume the RSS feed for weather watches offered by the National Weather Service. You'll use the XML::RSS module for reading an RSS feed. XML::RSS is available within many Linux distributions or from your favorite CPAN mirror. XML::RSS includes methods to both parse (read) and create (write) RSS feeds. | |||