Re: reg exp help
- From: daggerquill@xxxxxxxxx (Jay Savage)
- Date: Tue, 28 Jun 2005 12:44:04 -0400
On 6/28/05, Jeff 'japhy' Pinyan <japhy@xxxxxxxxxxxx> wrote:
> On Jun 28, DBSMITH@xxxxxxxxxxxxxx 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
--------------------
daggerquill [at] gmail [dot] com
http://www.tuaw.com
http://www.dpguru.com
http://www.engatiki.org
.
- Follow-Ups:
- Re: reg exp help
- From: Jay Savage
- Re: reg exp help
- References:
- Re: reg exp help
- From: Jeff 'japhy' Pinyan
- Re: reg exp help
- Prev by Date: Re: perl message passing module
- Next by Date: Re: reg exp help
- Previous by thread: Re: reg exp help
- Next by thread: Re: reg exp help
- Index(es):