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)

or

if (mary)
finger(goto mary)

if (jim)
finger(goto jim)


Any other ideas to avoid the same system call 3 times?




                                                                           
             Jeff 'japhy'                                                  
             Pinyan                                                        
             <[EMAIL PROTECTED]                                          To 
             rg>                       [EMAIL PROTECTED]              
                                                                        cc 
             07/21/2005 02:34          beginners@perl.org                  
             PM                                                    Subject 
                                       Re: code improvement using LABELS   
                                       within subroutines????              
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




On Jul 21, [EMAIL PROTECTED] said:

> I am wanting to improve my code b/c I am making 3 identical system calls.
> So I thought a subroutine with that one call and LABELS for each
condition
> would improve it.

> sub finger {
>
> open (GPG, "gpg --fingerprint |") or die "unable to open pipe sys call
> + (1)... Broken? $!";
>
> for (;<GPG>;) {
>   EXP: if ( /(?i)expires/ ) { ... }
>   FPR: if (/talx/ig .. /expire/ig) { ... }
     KEY: if ( /(?i)pub/ and /(?i)talx/) { ... }
> }  # END FOR LOOP
>
> close (GPG) or die "unable to close pipe sys call (0)... Broken? $!";
>
> }  # END ROUTINE

That looks fine.  There's really no *need* for the labels, though.  You're
not using them, except below, where you're using them incorrectly:

> &finger(goto EXP);

I think you just want to write:

   finger();

I haven't taken a guess at what function(goto XYZ) does, but if I had to,
I'd say it wouldn't end up calling the function at all, and just go to
XYZ, which might be a problem, given that (in your case) the label is
defined INSIDE a function.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart



-- 
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