in reply to How do you move within an array using foreach?
I'm a bit confused by your question as what you state in the question seems, to me, to not match the code comments. Perhaps if you were to provide sample output we might better understand. In the meantime, I am taking your question to mean "given start and end tokens in a file, how do I print out all lines from the start and end tokens?".
#!/usr/bin/perl -w use strict; my $start = qr/\Q[foo]\E/; my $end = qr/\Q[foo2]\E/; while ( <DATA> ) { if ( /$start/ .. /$end/ ) { print; } } __DATA__ ; ; foo file ; [foo] a=1 b=2 c=3 [foo2] d=4 e=5 f=6
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do you move within an array using foreach?
by flounder99 (Friar) on Oct 10, 2002 at 19:00 UTC | |
|
Re (2): How do you move within an array using foreach?
by VSarkiss (Monsignor) on Oct 10, 2002 at 18:40 UTC | |
|
Re: Re: How do you move within an array using foreach?
by P0w3rK!d (Pilgrim) on Oct 10, 2002 at 18:48 UTC | |
by VSarkiss (Monsignor) on Oct 10, 2002 at 19:15 UTC | |
by P0w3rK!d (Pilgrim) on Oct 10, 2002 at 19:28 UTC | |
by P0w3rK!d (Pilgrim) on Oct 10, 2002 at 18:51 UTC | |
by jj808 (Hermit) on Oct 10, 2002 at 19:31 UTC |