Exibir vários marcadores de mapa na API do Google Maps

trabalhando em algum código perl em um arquivo .cgi que percorre uma lista hash de endereços IP, depois executa cada endereço IP através de um serviço da web que retorna a latitude e longitude do endereço IP e, em seguida, ele precisa exibir cada endereço IP como um marcador em um mapa do google. A partir de agora eu o tenho percorrendo a lista de hash e imprimindo as coordenadas de cada endereço IP. O que não consigo descobrir é como exibir mais de um marcador de mapa no mapa do google. Atualmente, estou apenas testando-o codificando valores para as variáveis $ latitude e $ longitude. Eu estou pensando que precisa haver algum tipo de loop no javascript que percorrerá e atribuirá cada coordenada, mas não tenho idéia de como abordar iss

Update: eu adicionei o código da primeira resposta e a lista foi impressa com sucesso fora do loop. O problema que estou tendo agora é que o mapa do google não será mais carregado. Eu reduzi o problema ao javascript, onde as variáveis de latitudes e longitudes atribuíram seu valo

unless ($result->fault) {

# Print out the results one by one
my $latitude = "LATITUDE = " . $result->valueof('//LATITUDE') . "\n";
my $longitude = "LONGITUDE = " . $result->valueof('//LONGITUDE') . "\n";

#print "MESSAGE = " . $result->valueof('//MESSAGE') . "\n";


$lats .= $latitude . ',';
$lons .= $longitude . ',';


} else {

print "IP2Location Web Service Failed!\n";
print join ', ',
$result->faultcode,
$result->faultstring,
$result->faultdetail;

}
}

chop $lats;
chop $lons;

#printing here to test if the variable is making it out of the loop
print $lats ;
print $lons ;

print <<ENDHTML;
<html>
  <head>
<title>IP Lookup Map</title>
<meta name="viewport"
    content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<style type="text/css">
  html, body, #map_canvas {
    margin: 0;
    padding: 0;
    height: 90%;
    width: 90%;
  }
</style>
<script type="text/javascript"
    src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
//If I comment out the following variables the map will load, not sure what the problem is
    var latitudes = "$lats".split(",");
    var longitudes = "$lons".split(",");

  var map;
  function initialize() {
    var myOptions = {
      zoom: 7,
      center: new google.maps.LatLng(44, -90),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map_canvas'),
        myOptions);

    // Creating a marker and positioning it on the map
    for(var i = 0; i < latitudes.length; i++){
        var latitude = latitudes[i];
        var longitude = longitudes[i];
    // Creating a marker and positioning it on the map
        var marker = new google.maps.Marker({
        position: new google.maps.LatLng(latitude,longitude),
        map: map
    });
    }
  }

  google.maps.event.addDomListener(window, 'load', initialize);
</script>

questionAnswers(4)

yourAnswerToTheQuestion