thank you,

I will consider all of these.


derek



                                                                           
             "Scott R. Godin"                                              
             <[EMAIL PROTECTED]                                             
             .net>                                                      To 
                                       [email protected]                  
             07/22/2005 02:10                                           cc 
             PM                                                            
                                                                   Subject 
                                       Re: code improvement using LABELS   
                                       within subroutines????              
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Jeff 'japhy' Pinyan wrote:
> On Jul 21, [EMAIL PROTECTED] said:
>
>> ok thanks but that does not really help. Sorry.
>> your right about finger(), but based on my code I want to execute a
>> certain
>> block label
>>
>> if ( mary)
>> finger (mary)
>>
>> if (jim)
>> finger(jim)
>
>
> Oh, then in that case:
>
>   finger($user);
>
>   # ...
>
>   sub finger {
>     my $who = shift;
>
>     open GPG, ...;
>
>     if ($who eq 'mary') {
>       # ...
>     }
>     elsif ($who eq 'jim') {
>       # ...
>     }
>
>     close GPG;
>   }
>

Then again, if you're using Perl 5.7.3 or later, you can use Switch:

use Switch;
use Carp;
finger($user);

sub finger
{
     my $who = shift || croak "no user supplied";
     open GPG, ...;
     switch($who) {
         case 'mary' { #... }
         case 'jim'  { #... }
         case 'blah {
             # multiple lines
             # ...
         }
     }
     close GPG;
}

perldoc Switch for details. :)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to