in reply to Trapping errors
Now the questions: 1. if ($1), $1 is a special variable used for the first successful match in a regex, but you don't seem to be using any regex. 2. Nor sure you should use an eval, it might be better to see if $latlong is defined and is a reference (I assume it should be a reference) to some data structure that is also properly defined. 3. If you really want to use eval, then you should really check the value of $@, which contains the Perl error message from the last eval (but AppleFritter++ has already mentioned this to you. In brief, you do not seem to be doing the steps needed to catch an error, I am not too surprised that you don't catch any.if ($loop < 10) { $geocoder = Geo::Coder::Google->new(apiver => 3); eval{ $latlong = $geocoder->geocode(location => $location); if ($1){ print "!!! !!! !!! --- Couldn't get location : $locati +on --- !!! !!! !!!\n"; }else{ $map_coords = $latlong->{geometry}{location}{lat} . " +" . $latlong->{geometry}{location}{lng}; print ( " job no.\: $job_count $job_title \=\=\> $department $ +location $map_coords \n" ); $loop++; } } }
Now, of course, all the above is in part speculation, as I said, I do not know this module (and have no time right now to go through it), but I still hope it might help you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trapping errors
by mcoblentz (Scribe) on Jul 23, 2014 at 23:17 UTC | |
by Laurent_R (Canon) on Jul 24, 2014 at 06:37 UTC |