[Perl-unix-users] listing subroutines defined locally in a class

2003-01-10 Thread Martin Moss



All,
 
I want to be able to take a class and in it's 'new' 
subroutine do a check to ensure that each class has been given configuration 
information for each subroutine it has defined locally within that class. The 
problem I have is that I don't know how to differentiate between methods created 
in a base class, methods created by included modules (through the use of the 
use) and so on. I simply only want those that exist locally to the 
class.
 
I came across the following code :-
 
sub methods{  my $self = 
shift;  my $class = ref($self) || $self;  my @list;  
no strict 'refs';
 
  print STDERR Dumper(keys 
%{"${class}::"});  # Based on methods_via() in perldb5.pl  
foreach my $name (grep {defined &{${"${class}::"}{$_}}} keys 
%{"${class}::"}) {  push @list, 
$name;  }
 
  return \@list;}
 
But this doesn't quite work out, without having a 
long list of 'ignore' keywords. And then it wouldn't be very future proof. Does 
anybody have any ideas?
 
Regards
 
Marty
 

Example of How I see this working, parent and base 
classes:-
 
package ParentClass;
 
use base qw(BaseClass);
use vars qw(%methods);
 
%methods=(  
'_load' =>  $configdata,
  
'list' =>  $configdata,
  
'anothersub' =>  $configdata,
            
    );
 
 
 
package BaseClass;
 
sub new 
{
    blahusualblah
    
$self->_check_methods();
}
 
sub methods
{
    #returns a list of methods for 
this class, which doesn't include special ones like  BEGIN, croak, AUTOLOAD 
etc...
}
 
sub _check_methods
{
    
my $self=shift;
    my $class=ref($self)||$self;
 
my 
@methods=@{$self->methods()};
 
    foreach my $method (@methods)
    {
        unless 
(exists($self->methods->{$method}))
        {
            die 
"No configuration supplied for $method for $class";
        }
    }
}
    



Re: [Perl-unix-users] listing subroutines defined locally in a class

2003-01-10 Thread Martin Moss
Not the solution I was looking for:-)

You need to go lookup the unsubscribe options at activestate.com, can't
remember what they are offhand, but nobody on this list has the actual power
to take you off the list,

Regards

Marty
- Original Message -
From: "J. Utermehle" <[EMAIL PROTECTED]>
To: "Martin Moss" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Friday, January 10, 2003 7:09 PM
Subject: Re: [Perl-unix-users] listing subroutines defined locally in a
class


> take me off the list
>
> On Fri, 10 Jan 2003, Martin Moss wrote:
>
> > Date: Fri, 10 Jan 2003 18:56:13 -
> > From: Martin Moss <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: [Perl-unix-users] listing subroutines defined locally in a
class
> >
> > All,
> >
> > I want to be able to take a class and in it's 'new' subroutine do a
check to ensure that each class has been given configuration information for
each subroutine it has defined locally within that class. The problem I have
is that I don't know how to differentiate between methods created in a base
class, methods created by included modules (through the use of the use) and
so on. I simply only want those that exist locally to the class.
> >
> > I came across the following code :-
> >
> > sub methods
> > {
> >   my $self = shift;
> >   my $class = ref($self) || $self;
> >   my @list;
> >   no strict 'refs';
> >
> >   print STDERR Dumper(keys %{"${class}::"});
> >   # Based on methods_via() in perldb5.pl
> >   foreach my $name (grep {defined &{${"${class}::"}{$_}}} keys
%{"${class}::"}) {
> >   push @list, $name;
> >   }
> >
> >   return \@list;
> > }
> >
> > But this doesn't quite work out, without having a long list of 'ignore'
keywords. And then it wouldn't be very future proof. Does anybody have any
ideas?
> >
> > Regards
> >
> > Marty
> >
> > 
> > Example of How I see this working, parent and base classes:-
> >
> > package ParentClass;
> >
> > use base qw(BaseClass);
> > use vars qw(%methods);
> >
> > %methods=(
> >   '_load' =>  $configdata,
> >   'list' =>  $configdata,
> >   'anothersub' =>  $configdata,
> > );
> >
> >
> >
> > package BaseClass;
> >
> > sub new
> > {
> > blahusualblah
> > $self->_check_methods();
> > }
> >
> > sub methods
> > {
> > #returns a list of methods for this class, which doesn't include
special ones like  BEGIN, croak, AUTOLOAD etc...
> > }
> >
> > sub _check_methods
> > {
> > my $self=shift;
> > my $class=ref($self)||$self;
> >
> > my @methods=@{$self->methods()};
> >
> > foreach my $method (@methods)
> > {
> > unless (exists($self->methods->{$method}))
> > {
> > die "No configuration supplied for $method for $class";
> > }
> > }
> > }
> >
> >
>
>

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



[Perl-unix-users] [OT] Unsubscribe

2003-01-10 Thread Timothy A. Canon
How to unsubscribe (and a wealth of other information) is listed in the
mail headers.

List-Unsubscribe:
,



Tim

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]] On 
> Behalf Of Martin Moss
> Sent: Friday, January 10, 2003 1:09 PM
> To: J. Utermehle
> Cc: [EMAIL PROTECTED]; 
> [EMAIL PROTECTED]
> Subject: Re: [Perl-unix-users] listing subroutines defined 
> locally in a class
> 
> 
> Not the solution I was looking for:-)
> 
> You need to go lookup the unsubscribe options at 
> activestate.com, can't remember what they are offhand, but 
> nobody on this list has the actual power to take you off the list,
> 
> Regards
> 
> Marty
> - Original Message -
> From: "J. Utermehle" <[EMAIL PROTECTED]>
> To: "Martin Moss" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Friday, January 10, 2003 7:09 PM
> Subject: Re: [Perl-unix-users] listing subroutines defined 
> locally in a class
> 
> 
> > take me off the list

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



[Perl-unix-users] Creating XML file using XML::LibXML (fwd)

2003-01-10 Thread Devi .M
Hello All,
I am able to create a XML file but unable to put a DOCTYPE entry
where I could give the DTD file in it using perl XML::LibXML. I tried all
the man pages and even online helps but I could not find anything. I found
this option for XML::Writer but since I am using XML::LibXML, I want to
know is there any possibility to add this?


Thanks in advance,
Devi


-
 Much of the excitement we get out of our work is 
that we don't really know what we are doing.



___
Perl-XML mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs