> OPERATION, FOO, AND BAR. I want to read in this one section
> at a time.
I think it would be simpler to read the entire thing in at once, like
so:
open FILE,'<whatever.txt';
my $file = '';
{ local $/ = undef;
$file = <FILE>; }
> I want to know how to read this in by
> section (as oposed
> to line) that ends with (*ENDS).
And split on *ENDS, like so:
@file = split /\n\*ENDS\n/m,$file;
> Then I want to know how to
> tell what
> section I'm in (*DESCRIPTION), and then I want to know where
> to do my search
> and replace (s/INFILE/TEST/). I hope someone can help me
> out. Thanks so
> much for your continued patience!
foreach $block (@file) {
my $section = $1 if /\n\*([A-Z]+)\n/m;
s/INFILE/TEST/m if $section eq 'DESCRIPTION';
s/LAYER/MYLAYER/m if $section eq 'LAYERS';
}
> Example Text
> <snip>
> ; Test
> ; Test
> *DESCRIPTION
> ; More comments
> INFILE = blach
> OUTFILE = test
> ;
>
> ;
> *ENDS
> ;
> ;
> *LAYERS
> LAYER=1
> ;
> *ENDS
> ;
> <snip>
Am I understanding your problem correctly? Hope that helps.
-dave
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]