WEB开发网
开发学院软件开发Java 如何用 Eclipse 调试 Perl 应用程序 阅读

如何用 Eclipse 调试 Perl 应用程序

 2009-12-19 00:00:00 来源:WEB开发网   
核心提示: 清单 3. RSS Feeder 脚本usestrict;usewarnings;useXML::RSS;useLWP::UserAgent;my$ua=LWP::UserAgent->new();my$feeds={"MCslp"=>'http://ww


清单 3. RSS Feeder 脚本
 
use strict; 
use warnings; 
use XML::RSS; 
use LWP::UserAgent; 
my $ua = LWP::UserAgent->new(); 
my $feeds = { "MCslp" => 'http://www.mcslp.com/wp-rss2.php' }; 
foreach my $feed ( sort keys %{$feeds} ) 
{ 
  my ($rss) = parse_rss_fromurl( $feeds, $ua, $feed ); 
  parse_items_to_text($rss);   
} 
 
sub parse_rss_fromurl 
{ 
  my $feeds  = shift; 
  my $ua    = shift; 
  my $feed   = shift; 
  my $response = $ua->get( $feeds->{$feed} ); 
  my $rss; 
  if ( $response->is_success ) 
  { 
    $rss = XML::RSS->new(); 
    $rss->parse( $response->{_content} ); 
  } 
  return ($rss); 
} 
 
sub parse_items_to_text 
{ 
  my ($feed) = @_; 
  foreach my $i ( @{ $feed->{items} } ) 
  { 
    next unless defined($i); 
    my $len = length( $i->{"title"} ); 
    print($i->{"title"}, 
       "\n", 
       ( '=' x $len ), 
       "\n", 
       $i->{"description"}, 
       "\n\n", 
       $i->{"link"}, 
       "\n\n" ); 
  } 
} 

上一页  3 4 5 6 7 8 9 10  下一页

Tags:如何 Eclipse 调试

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接