Using perl Syntax Highlighting
#!/usr/bin/perl
use strict;
use XML::RSS;
use LWP;
use Template;
use CGI;
use CGI::Carp qw( fatalsToBrowser );
sub _init {
my( $cgi, $url, $ua, $request, $response, $canal );
$cgi = CGI->new();
$url = $cgi->param('url') || 'http://www.cofradia.org/backend.php';
$ua = LWP::UserAgent->new;
$ua->agent('get_rdf/1.0 (' . $ua->agent . ')');
$request = HTTP::Request->new( GET => $url );
$response = $ua->request( $request );
croak "Error: No se pudo obtener la pagina pedida o el contenido es inválido"
unless $response->is_success;
$canal = build_data( $response->content );
show_content( $canal );
}
sub build_data {
my( $content, $rss, $canal );
$content = shift;
$rss = XML::RSS->new();
$rss->parse($content);
$canal->{'nombre'} = $rss->{'channel'}->{'title'};
foreach my $item ( @{ $rss->{'items'} } ) {
push @{ $canal->{'notas'} }, { titulo => $item->{'title'},
liga => $item->{'link'},
};
}
return $canal;
}
sub show_content {
my ( $canal, $dir, $tt, $datos );
$canal = shift;
$tt = Template->new({
PRE_PROCESS => 'config',
});
$datos = {
titulo => $canal->{'nombre'},
noticias => $canal->{'notas'},
};
print "Content-type: text/html\n\n";
$tt->process( 'rss.tt', $datos ) or die "Error: $tt->error";
}
_init();
use strict;
use XML::RSS;
use LWP;
use Template;
use CGI;
use CGI::Carp qw( fatalsToBrowser );
sub _init {
my( $cgi, $url, $ua, $request, $response, $canal );
$cgi = CGI->new();
$url = $cgi->param('url') || 'http://www.cofradia.org/backend.php';
$ua = LWP::UserAgent->new;
$ua->agent('get_rdf/1.0 (' . $ua->agent . ')');
$request = HTTP::Request->new( GET => $url );
$response = $ua->request( $request );
croak "Error: No se pudo obtener la pagina pedida o el contenido es inválido"
unless $response->is_success;
$canal = build_data( $response->content );
show_content( $canal );
}
sub build_data {
my( $content, $rss, $canal );
$content = shift;
$rss = XML::RSS->new();
$rss->parse($content);
$canal->{'nombre'} = $rss->{'channel'}->{'title'};
foreach my $item ( @{ $rss->{'items'} } ) {
push @{ $canal->{'notas'} }, { titulo => $item->{'title'},
liga => $item->{'link'},
};
}
return $canal;
}
sub show_content {
my ( $canal, $dir, $tt, $datos );
$canal = shift;
$tt = Template->new({
PRE_PROCESS => 'config',
});
$datos = {
titulo => $canal->{'nombre'},
noticias => $canal->{'notas'},
};
print "Content-type: text/html\n\n";
$tt->process( 'rss.tt', $datos ) or die "Error: $tt->error";
}
_init();
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4
saben que librerías debo tener... saludos...