[Omaha.pm] XML::Twig error handling

Jay Hannah jay.hannah at iinteractive.com
Mon Oct 22 12:34:44 PDT 2012


On Oct 22, 2012, at 2:23 PM, Justin Esbenshade <jesbenshade at omnihotels.com> wrote:
> Lot's of if's.
> 
>   my ($PN) = $PR->first_child('Customer')->first_child('PersonName');
>   if ($PN) {
>      $Res{firstName} = $PN->first_child('c:firstName')->text if ( $PN->first_child('c:firstName') );
>      $Res{lastName} = $PN->first_child('c:lastName')->text if ( $PN->first_child('c:lastName') );
>   }
> 
>   my ($A) = $PR->first_child('Addresses');
>   my ($NA) = $A->first_child('NameAddress') if ($A);
>   if ($NA) {

Thanks. I think I'm liking Try::Tiny better...?

   my ($sql, $connection, $table);
   try { $sql =        $s->first_child('sql')->text; };
   try { $connection = $s->first_child('connection')->text; };
   try { $table =      $s->first_child('table')->text; };

Ponder,

j





More information about the Omaha-pm mailing list