> My question is whethor or not its better to parse the data as
> I load the array
> from the program output, or parse the array after the fact,
> or parse the array
> after the fact multiple times In either case I seem to get
> lost in trying to
> use a foreach and shift at the same time, e.g.:
>
> #### TRYING TO PARSE PURGE EVERYTHING TO "Defined Filter
> List" +two elements)
> my @filters = `/opt/OV/bin/ovfiltercheck`;
> foreach ( @filters ) {
> if ( m/Defined Filter List/ ) { # IF FIND FILTER SECTION
> shift; # DELETE "Defined Filter List"
> shift; # DELETE "================"
> last; # EXIT FOREACH LOOP
> } else {
> shift; # DELETE ELEMENTS
> }
> }
How about something like:
# simply fills the arrayy with all lines but the Header lines
# is that what you wanted to do?? It is hard to tell.
# you may want to fine tune the expr matches.
my @filters = `/opt/OV/bin/ovfiltercheck`;
foreach ( @filters ) {
next if =~ /Defined Filter List/;
next if =~ /Defined Set List/;
next if =~ /=+/;
# Now do something with the good data
# like print or print to a file, or another array.
}
> # Make another foreach loop to dump elements after "Defined Set List"
> print @filters;
That depends what you want to do with this array. Do you just want to print
them or write to a file, or use later in program?
> my ( @filters, $filters_begin, $filters_end) ;
> open OVFILTERCHECK, "/opt/OV/bin/ovfiltercheck |" || die
> "Error, can't open:
> $!\n";
> while (<OVFILTERCHECK>) {
> if ( m/Defined Filter List/ ) { # WHEN I GET TO THE FILTER LIST
> $filters_begin = 1; # SET A FLAG INDICATING SAME
> }
> if ( m/Defined Set List/ ) { # WHEN PASS THE FILTER SECTION
> last; # TERMINATE ARRAY LOADING
> }
> if ($filters_found) { # IF FILTER SECTION HAS BEGUN
> $filters[$.++] = $_; # SAVE VALID FILTER NAMES
> TO @FILTERS
You can accomplish all of this in the first loop, open a out file and write
to it. Give it a try and learn this. If you get stuck, post again.
HTH,
JIm
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]