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.