Michael Kraus <[EMAIL PROTECTED]> wrote: : Just wondering if this code snippet will behave as expected, : and if not then why not? :)
No, I don't think so. One error is in using the qq() operator instead of the qw() operator. Even with that fix, perl throws syntax errors. : --START-- : our %InheritableClassData = ( : DBH => undef, : Q => undef, : Handler => undef, : ); : : foreach (qq(DBH Q Handler)) { : sub $_ { : shift; : $InheritableClassData{$_} = shift if @_; : return $InheritableClassData{$_}; : } : } We could test solutions by examining the symbol table. When creating new functions (or methods in an object), perl adds entries to the symbol table (%::). If we store the keys previous to setting the functions, we can delete() them from the table keys afterward and find if any new symbols were added. use Data::Dumper 'Dumper'; . . . # store current symbol table keys my @prev_keys = keys %::; foreach my $method ( keys %InheritableClassData ) { no strict 'refs'; *$method = sub { shift; $InheritableClassData{$_} = shift if @_; return $InheritableClassData{$_}; }; } # store current symbol table my %new_table = %::; # delete old keys delete @new_table{ @prev_keys }; print "Added symbol table entries\n", Dumper \%new_table; __END__ I get: Added symbol table entries $VAR1 = { 'Handler' => *::Handler, 'Q' => *::Q, 'DBH' => *::DBH }; HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>