#!/usr/bin/perl -w use strict; use XML::Parser; use LWP::Simple; my $feed; open( FH, ">feed.xml") or die "Error: $!\n"; $feed = get("http://rss.news.yahoo.com/rss/science"); print FH $feed; my $parser = new XML::Parser ( Handlers => { Start => \&hdl_start, End => \&hdl_end, Char => \&hdl_char, } ); $parser->parsefile("feed.xml"); sub hdl_start { my ($p, $ele, %attribs) = @_; $attribs{'string'} = ''; $feed = \%attribs; } sub hdl_end { my ($p, $ele) = @_; display_feed($feed) if $ele eq 'title'; display_feed($feed) if $ele eq 'link'; } sub hdl_char { my ($p, $str) = @_; no strict 'refs'; $feed->{'string'} .= $str; } sub display_feed { my $attribs = shift; $attribs =~ s/\n//g; print "$attribs->{'string'}\n\n"; }