Hi, I'm running ActiveState build 623 (Perl v5.6.0) on Win2k, reading C++ source files as input, and I need to produce XML documents as output. In general I'm reading the C++ code and storing code blocks in a hash of anonymous arrays. Then I go back and read each array and use XML::Generator to create the documents. Things were going well until I tried to put a foreach loop into the XML generation section....
It appears I need to keep loops away from XML::Generator. True? The code I have so far looks clumsy to me, you too? I'd like to avoid slurping the whole file, is this the best way to extract blocks of code? Does it look like I'm on the right track, or can you see a cliff ahead? Thank you, Martin ---------------- use strict; use XML::Generator; my # variables listed here # open (FIL, "$ARGV[0]") or die "Can't open input file: $!"; while (<FIL>) { if (/(typedef enum.+)/) { $readline = 1; $key = $1; push(@{$enum{$key}}, $_); } elsif (/}(.+);/ and $readlines) { push(@{$enum{$key}}, $1); $readlines = 0; $key = ""; } elsif ($readlines) { push(@{$enum{$key}}, $_); } } foreach my $enumkey (keys %enum) { open (RPT, ">$enumkey.xml"); my @lines = @{$enum{$enumkey}}; my $xml = $gen->Enumeration( $gen->Name("$lines[$#lines]"), $gen->Description(""), # If I remove the foreach block below, no compile errors. foreach ($lines[2] .. $lines[$#lines-1]) { $name = /\s+(\w+)/; $desc = /\/\/(.*)/; $gen->Name("$name"), $gen->Description("$desc"), } $gen->Remark(""), $gen->Note(""), $gen->Example("")); print RPT "$xml"; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]