No, probably not. But I wonder how he'd get there if he were. Well, I've just read about Google::Directions, so let's find out!
#!/usr/bin/env perl use v5.14; use warnings; use Google::Directions::Client; use Mojo::DOM; my $origin = shift // die "\n\tUsage: $0 starting_address\n\n"; my %params = ( origin => $origin, destination => '800 S Rolling Rd, Catonsville, MD 21228', ); my $response = Google::Directions::Client->new->directions(%params); die $response->status unless $response->status eq 'OK'; my $leg = $response->routes->[0]->legs->[0]; my $miles = sprintf "%.1f", $leg->distance / 1609.344; my $minutes = int 0.5 + $leg->duration / 60; say "Approximately $miles miles (about $minutes minutes)"; while (my($i, $step) = each @{$leg->steps}) { printf "%3d. ", $i+1; say Mojo::DOM->new( $step->html_instructions )->all_text; }
I've just hard coded in the address to DCBPW and used Mojo::DOM to scrub the HTML directions. I thought about using Term::ReadLine to prompt for the starting address, but I decided it was just as easy to grab it off the command line.
$ ./dcbpw.pl '1600 Pennsylvania Ave, Washington, DC' Approximately 34.9 miles (about 52 minutes) 1. Head north on 17th St NW toward H St NW 2. Take the 1st right onto H St NW 3. Turn left onto New York Ave NW 4. Continue onto K St NW 5. Turn left onto 7th St NW 6. Take the 2nd right onto New York Ave NW 7. Continue onto US-50 E Entering Maryland 8. Take the Balt-Wash Pkwy exit on the left toward Baltimore 9. Merge onto MD-295 N 10. Take the exit onto I-195 W toward I-95/Catonsville 11. Exit onto S Rolling Rd Destination will be on the leftSee you in Catonsville!
Nice! Very hand and I LOVE the example you picked :)
Posted by: Brock Wilcox | 02/02/2012 at 07:42 AM