#!/usr/local/bin/perl -w # test parser prior to plugging into larger script # to replace the old function. use strict; use Env; my $file = "$HOME/archive_bin/configs/dtfr_archiver.conf"; my ($class,$type,$var,$rval,%config); open(F,$file) or die("Can't open it: $!\n"); while ( ) { chomp; my $current_line = $_; my $ok = "^(macro|define|rule)"; next if ( /^#/ ); # skip comments next if ( /^\n/ ); # skip newlines and all only-spaces my $check = (/$ok\s+\w+\s+\{/ .. /^\}/); do { if ( $check == 1 ) { $current_line =~ /^([a-z]+)/; $class = $1; print "class: $class\n"; # do more checking here $current_line =~ /^.*? (\w+)\s+\{/; # do more checking here $type = $1 # do more checking here print "type: $type\n\n"; # do more checking here } if ( $check !~ /EO/ and $check > 1 ) { if ( $current_line =~ /=/ ) { ($var,$rval) = split(/=/,$_); $var =~ tr/ //d; $rval =~ tr/" ;//d; print "var: $var and rval: $rval\n"; #$config{$type}{$var} = $rval; } } } if $check; }