#
!C:perlinperl-w
use strict;
use LWP :: Simple;
use CGIqw( : standard);
my $url = " http://slashdot.org/slashdot.xml " ;
my $cache = " cache " ;
print header;
# savetheresultsinthecachefile
my $doc = get( $url );
if ( defined $doc ){
open (CF , " >$cache " ) || die " writingtocache:$! " ;
print CF $doc ;
close CF;
}
# parsetheXMLfileandoutputtheTITLEandURL
print " <h2>slashdot.org'sheadlinesasof</h2> " ;
open (CF , $cache ) || die " cannotopenthecache:$! " ;
my ( $title , $link );
while ( < CF > ){
if (m ,< title > ( .* ) </ title >, ){
$title = $ 1 ;
}
if (m ,< url > ( .* ) </ url >, ){
$link = $ 1 ;
print qq( < ahref = " $link " > $title </ a >< br /> n);
}
}
close CF;
use strict;
use LWP :: Simple;
use CGIqw( : standard);
my $url = " http://slashdot.org/slashdot.xml " ;
my $cache = " cache " ;
print header;
# savetheresultsinthecachefile
my $doc = get( $url );
if ( defined $doc ){
open (CF , " >$cache " ) || die " writingtocache:$! " ;
print CF $doc ;
close CF;
}
# parsetheXMLfileandoutputtheTITLEandURL
print " <h2>slashdot.org'sheadlinesasof</h2> " ;
open (CF , $cache ) || die " cannotopenthecache:$! " ;
my ( $title , $link );
while ( < CF > ){
if (m ,< title > ( .* ) </ title >, ){
$title = $ 1 ;
}
if (m ,< url > ( .* ) </ url >, ){
$link = $ 1 ;
print qq( < ahref = " $link " > $title </ a >< br /> n);
}
}
close CF;