Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Please help cri...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 11052 of 11526
Post > Topic >>

Please help critcize and shorten my sub code

by rich.japh@[EMAIL PROTECTED] (Richard Lee) May 10, 2008 at 07:21 PM

I dont know how to go through the array over and over again pending on 
my previous search so I ended up writing it like below which works.. but 
looks really really
inefficient..


sub dd_fact {
     my $routename = ****ft;
     my $routegroupid;
     my $trunkgroupid;
     my $carriername;
     my $carrier_active;
     my $carrierid;
     AHI: for (@[EMAIL PROTECTED]
) {
        if (exists $_->{outsideroute_group_m}{route_name}
             and $_->{outsideroute_group_m}{route_name} eq "$routename") {
             $routegroupid = $_->{outsideroute_group_m}{route_group_id};
             last AHI;
        }
     }

     EWF: for (@[EMAIL PROTECTED]
) {
        if (exists $_->{outsideroute_trunk_m}{route_group_id}
             and $_->{outsideroute_trunk_m}{route_group_id} eq 
"$routegroupid") {
             $trunkgroupid = $_->{outsideroute_trunk_m}{trunkgroup_id};
             last EWF;
        }
     }

     WWW: for (@[EMAIL PROTECTED]
) {
        if (exists $_->{outsideotrunkgroup_m}{trunkgroup_id}
             and $_->{outsideotrunkgroup_m}{trunkgroup_id} eq 
"$trunkgroupid") {
             $carrierid = $_->{outsideotrunkgroup_m}{carrier_id};
             last WWW;
        }
     }

     for (@[EMAIL PROTECTED]
) {
        if (exists $_->{outsidecarrier_m}{carrier_id}
             and $_->{outsidecarrier_m}{carrier_id} eq "$carrierid") {
             $carriername = $_->{outsidecarrier_m}{carrier_name};
             $carrier_active = live($_->{outsidecarrier_m}{active});
             return($trunkgroupid,$carriername,$carrier_active);
        }
     }
}
 




 8 Posts in Topic:
Please help critcize and shorten my sub code
rich.japh@[EMAIL PROTECTE  2008-05-10 19:21:05 
Re: Please help critcize and shorten my sub code
Jenda@[EMAIL PROTECTED]   2008-05-11 02:05:06 
Re: Please help critcize and shorten my sub code
rich.japh@[EMAIL PROTECTE  2008-05-10 20:20:13 
Re: Please help critcize and shorten my sub code
Jenda@[EMAIL PROTECTED]   2008-05-11 03:02:04 
Re: Please help critcize and shorten my sub code
rich.japh@[EMAIL PROTECTE  2008-05-10 23:03:58 
Re: Please help critcize and shorten my sub code
Peter@[EMAIL PROTECTED]   2008-05-11 05:56:15 
Re: Please help critcize and shorten my sub code
Jenda@[EMAIL PROTECTED]   2008-05-11 15:44:09 
Re: Please help critcize and shorten my sub code
rob.dixon@[EMAIL PROTECTE  2008-05-11 20:57:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 11:57:13 CDT 2008.