use zUtil;
use locale; 

sub xfmhandler
{
   $html = shift;
   my( @rValue ) = ();
   my( $count, $row, $col, $rank, $artist, $song, $newsong, $text );
   my( $done );

   #print "=------------------ xfmhandler --------------------=\n";

   my $table = zUtil::getNthItemNew( 9, $html, "<table", "</table>" );

   #print "table: $table\n";
   #exit;


   $count = 3;
   while( $count < 12 )
   {       
       $row = zUtil::getNthItemNew( $count, $table, "<tr", "</tr>" );
       $text = zUtil::getNthItemNew( 2, $row, "<td", "</td>" );       

 #      print "searching in: $text\n";

       $text =~ s/\>\s+/\>/gs;
       $text =~ s/\s+\</\</gs;
       if( $text =~ /^.*?\>(\w.*?)\</si )
       {
#	   print "Found 1: $1\n";
	   $artist = $1;
	   
	   $text = $';
#	   print "searching in: $text\n"; 
	   if( $text =~ /^.*?\>([\w].*?)\</si )
	   {
               $song = $1;
#	       print "Found 2: $1\n";
	   }
       }
       
#       $artist =~ s/\<.+?\>//gs;
#       $song =~ s/\<.+?\>//gs;


      #print "Artist: $artist\n";
       #print "Song: $song\n\n";


       push @rValue,
       {
	   'rank' => $count - 2,
	   'artist' => $artist,
	   'song' => $song
       };
        
       $count = $count + 1;
   }


   return @rValue;
}

return 1;

