in reply to Example using LWP::Simple

Here is a simple example I use to grab the currently playing song on KCRW.com and display it on the console window as well as write it to a playlists file

#!perl use strict; use LWP::Simple; my $url = 'http://www.kcrw.com/'; my $sleep_time = 120; my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = loc +altime; my $playlist = 'playlist.txt'; # What do you want to find out about my $start = "<a href=\"javascript:KCRWmusicAlbum.*\">"; my $stop1 = "<\/a> by <a href=\"javascript:KCRWmusicArtist.*\">"; my $stop2 = "<\/a> at"; my @playlist; my $last_song; while ($hour < 14) { # only until 2p central die "Couldn't get $url" unless (my $content = get $url); # search the $content for the $kw $content =~ m/$start(.*)$stop1(.*)$stop2/i; if ($1 ne $last_song) { my %song = ('SONG' => $1, 'SINGER' => $2); push(@playlist, \%song); $last_song = $1; print "Now playing: '$1' by $2\n"; open PL, ">>$playlist" or die "Cannot open $playlist: $!"; print PL "$1|$2\n"; close PL; } sleep $sleep_time; }