Can someone give some script suggestions.
#!/usr/bin/perl -w use strict; use DBI; use Google::Directions::Client; my $hostname = "localhost"; my $db = "sugarcrm"; my $dsn = "dbi:mysqlPP:database=$db;host=$hostname"; my $dbh = DBI->connect($dsn, "root", "skynet") or die 'CANT CONNECT!!! +'; my $drh = DBI->install_driver("mysqlPP"); #CREATE AND EXECUTE QUERY my $sth = $dbh->prepare("SELECT p.id, p.primary_address_street addres +s, p.primary_address_city city, p.primary_address_state state, p.prim +ary_address_postalcode zip FROM prospects p LEFT JOIN prospects_cstm pc ON p.id = pc.id_c WHERE deleted <> 1 AND pc.addr_status_c is null limit 0, 1000;"); $sth->execute; my ($id,$address1,$city,$prov,$postalcode,$dealer_id); my $count = 0; #BIND TABLE COLUMNS TO VARIABLES $sth->bind_columns(\$id,\$address1,\$city,\$prov,\$postalcode); while($sth->fetch()) { my $goog = Google::Directions::Client->new(); my $response = $goog->directions( destination => $address1 . ',' . $city . ',' . $prov +. ',' . $postalcode, origin => '467 W. Shaw Fresno, CA 93724', ); if ($response->status eq 'OVER_QUERY_LIMIT') { die "Error: OVER_QUERY_LIMIT"; } unless ($response->status eq 'OK') { my $upd = $dbh->prepare("UPDATE prospects_cstm SET addr_status='NO +T_FOUND'"); $upd->execute; print "Count: " . $count++ . "\t" . "ID: " . $id . "\t" . "Status +: " . $response->status . "\n"; next; } my $distance = sprintf "%.2f", $response->routes->[0]->legs->[0]- +>distance / 1000; my $duration = sprintf "%.2f", $response->routes->[0]->legs->[0]- +>duration / 60; my $upd = $dbh->prepare("UPDATE prospects_cstm SET distance_c='" . + $distance . "', duration_c=" . $duration . ", addr_status_c='" . $re +sponse->status . "', lat_c=" . $response->routes->[0]->legs->[0]->end_loc +ation->lat . ", lng_c=" . $response->routes->[0]->legs->[0]->end_loca +tion->lng . " WHERE id_c='" . $id . "'"); $upd->execute; print "Count: " . $count++ . "\t" . "ADDRESS: " . $address1 . "\t" + . "CITY: " . $city . "\t" . "STATE :" . $prov . "\t" . "Duration: " + . $duration . "\t" . "Distance: " . $distance . "\t" . "Status: " . +$response->status . "\n"; } $sth->finish;
Thank you in advance.

In reply to Google MapsAPI by drodinthe559

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.