On 6/28/05, Jay Savage <[EMAIL PROTECTED]> wrote:
> On 6/28/05, Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
> > On Jun 28, [EMAIL PROTECTED] said:
> >
> > > but here is another piece of code I tried and this worked as well
> > > considering the attachment:
> > >
> > > comments on the below block?
> > [snip]
> > > if (m/begin pgp public key block/ig) {
> > >   $lc=1;
> > > }
> > > if ( $lc==1){
> > >   print $_;
> > > }
> > > if (m/end pgp public key block/ig) {
> > >   $lc=0;
> > > }
> >
> > What comment do you want?  This is 100% identical to using a flip-flop,
> > except that you have an explicit variable holding the truth value.  It
> > starts as false.  If the first regex matches, then $lc is true.  If $lc is
> > true, print the current line.  If the second regex matches, then $lc is
> > false.
> >
> > Identical.  Use a flip-flop.  It's easier.
> >
> > --
> 
> Not quite. In this code, $lc is not set to zero until after the test
> for $lc == 1, so the "-----END.+" line will be printed. A flip-flop on
> the other hand--which you have now recommended at least twice--does
> exactly what he's looking for.
> 
> -- jay

I'm sorry, I read too fast. I thought in the original code the "begin"
was supressed. You are absolutely correct. The consecutive ifs yeild
exactly the same result as the flipflop. I hit send too hastily.

-- jay
--------------------
daggerquill [at] gmail [dot] com
http://www.tuaw.com
http://www.dpguru.com
http://www.engatiki.org

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