A lyrics script I coded in Perl

I coded this script today before I knew about the existence of moc-lyrics.pl

Oh well, here is my script if anyone wants it. It's my first complete, semi-functional perl script.


#!/usr/bin/perl
#This is a script for the MOC player that will fetch the lyrics of the currently
#playing song from metrolyrics.com. The lyrics change automatically when the song
#changes.
require LWP::UserAgent;
use HTTP::Request::Common;
use HTML::Entities;

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->agent("Mozilla/8.0");

sub getCurrentSongArtist {
return `mocp -i | grep 'Artist:' | sed -e 's/^.*: //' | tr "\n" " "`;
}

sub getCurrentSongTitle {
return `mocp -i | grep 'SongTitle:' | sed -e 's/^.*: //' | tr "\n" " "`;
}

sub getCurrentSongLyrics {

$currentSongInfoSearch = $_[0];
$currentSongInfoSearch =~ s/ /\+/g;
#trying metro lyrics first
my $lyricsFoundList = $ua->request(POST 'http://www.metrolyrics.com/search.php', [search => $currentSongInfoSearch, category => "artisttitle", action=> "Search"]);

$currentSongLyricsSearch = $lyricsFoundList->decoded_content;
$currentSongLyricsSearch =~ s/\n/ /g;

if ($currentSongLyricsSearch =~m//){
$currentSongLyricsURL = $1;
}

my $lyricsFetchRequestFoundList = $ua->request(GET "http://www.metrolyrics.com/$currentSongLyricsURL");
$lyricsFetchRequestHTML = $lyricsFetchRequestFoundList->decoded_content;
$lyricsFetchRequestHTML =~s/\n/ /g;

if ($lyricsFetchRequestHTML =~/(.*?)/m){
$currentSongLyrics = $1;
}

$currentSongLyrics = decode_entities($currentSongLyrics);
$currentSongLyrics =~ s// /g;
return " $_[0] \n ------- \n $currentSongLyrics";
}

$active = true;
while ($active){
$currentSong = &getCurrentSongArtist . &getCurrentSongTitle;

if ($currentSong ne $currentSongCheck){
system("clear");
print &getCurrentSongLyrics($currentSong);
}

$currentSongCheck = &getCurrentSongArtist . &getCurrentSongTitle;

sleep(3);
}

Here's a screenshot of it in action:
http://i118.photobucket.com/albums/o120/robertgame/2009-05-03-015731_1680x1050_scrot.jpg