my $Long = $contact->getElementsByTagName( "Longitude" ); my $long = $Long->item(0)->getChildAtIndex(0)->getData(); # declare lexical variable *outside the scope of the eval* my $BusUrl; # trap potential error eval { $BusUrl = $contact->getElementsByTagName( "BusinessUrl" ); }; # check if tag retrieval failed if($@) { # assign an empty (but defined) string #$BusUrl = ''; } $bus_url = $BusUrl->item(0)->getChildAtIndex(0)->getData(); # line 87 # change phone number format