Update: I didn't write code to compare versions, but lets say you do the above once for the old version, once for the new version, so you have two hashes:use File::Basename; opendir(DIR, "/template/dir") or die "can't open dir: $!"; # I'm guessing at the template extension if there is one @templates = grep { /\.tmpl$/ } readdir DIR; closedir DIR; my %printers; for my $file (@templates) { open (FH, $file) or die "Error opening $file: $!"; my $name; while (<FH>) { chomp; my ($tmp_name, $value) = split /\s*:\s*/; $name = $tmp_name if $tmp_name; $value =~ s/,$//; $printers{basename($file)}{$name}{$value} = undef; } close FH; } # Now %printers contains all valid printer attributes # and their values
my (%old, %new); ... for my $printer (sort keys %old) { print("Printer $printer not in new\n"), next unless exists $new{$printer}; for my $name (sort keys %{$old{$printer}}) { print("Attribute $name not in new for printer $printer\n"), next unless exists $new{$printer}{$name}; for my $val (sort keys %{$old{$printer}{$name}}) { print("Val $val not in new for printer $printer attrib $name\n"), next unless exists $new{$printer}{$name}{$val}; } } } # Then do the reverse comparision looping over %new # I'm sure you can figure that out
In reply to Re: Need to build attribute parser
by runrig
in thread Need to build attribute parser
by Lord Rau
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |