On Wed, Oct 03, 2001 at 09:48:32AM +0200, Josi Luis Sancho wrote: > I am using XML::Grove and Data::Grove::Visitor to parse SGML/XML > documents; the visitor package generates calls back by element names; > unfortunately I face dot-named elements and I MUST parse them by means of > identically dot-named subroutines.
You don't -have- to. There are various alternatives. You could encode all of your subroutine names in a consistent manner. For example, "foo_bar" would become "foo_5fbar", and "foo.bar" would become "foo_2ebar" (the encoding, btw, is basically URL encoding, but with _ as the prefix, instead of %). However, that's ugly, so I much prefer this upcoming solution. Use a hash. You're basically using the symbol table as a hash, make the relationship more formal. The keys of the hash are your element names, the values code references. %elements = ( "foo.bar" => sub { ... }, "foo_bar" => sub { ... }, ); Then, instead of having to say "&{'foo.bar'}(...)" you say "$elements{'foo.bar'}->(...)". With the solution you eventually found, even though you can create a subroutine with a dot in it, you still can't call that subroutine as you would one without such a dot. the code "foo.bar(...)" still causes warnings and errors; you'd have to say "&{'foo.bar'}(...)". Using a hash, to me, is much preferable because it has the added benefit of not polluting the symbol table. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]