Ask a Question related to PERL Modules, Design and Development.
-
Timothy Hinchcliffe #1
Module naming help
I have written 2 modules which I intend to upload to CPAN.
I have chosen the names "Class::MethodVars" and "Class::Framework", they
would both be uploaded in Class-Framework-??.??.tar.gz unless anyone has
better suggestions.
The first currently called Class::MethodVars allows you to tag a sub with
":Method" and get access to "this" (in various configurable forms).
Eg:
package MyClass;
use warnings;
use strict;
use Class::MethodVars qw( -fieldvars ),-field=>"internal_variable";
sub new :ClassMethod {
return bless({},__CLASS__); # Class is provided my the magic
of :ClassMethod
}
sub mymethod :Method {
my ($arg) = @_; # Note that object has been removed from @_
this->{internal_variable}++;
this->othermethod($arg);
${^_internal_variable}++; # This is an alias to this->{internal_variable}
}
"this" can be renamed and/or configured to be a variable (which is
automatically added to "use vars" to remain strict-safe).
The second module is currently called Class::Framework. It combines
Class::MethodVars with fields (as in "use fields") and Class::Accessor to
build an class for you.
Eg:
package MyClass;
use warnings;
use strict;
use Class::Framework
-fields=>qw( a b cde ), # creates with ->mk_accessors(qw( a b cde ));
-rofield=>"rofield", # creates with ->mk_ro_accessors(qw( rofield ));
-hiddenfield=>"hidden"; # No accessor created.
# new() is inherited for you.
sub concat_fields :Method {
return join("",this->a,this->b,this->cde,this->rofield,this->{hidden});
}
package main;
my $mc = MyClass->new(a=>1,b=>2,cde=>3,rofield=>4,hidden=>5);
print $mc->concat_fields; # Prints "12345"
__END__
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
[url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Timothy Hinchcliffe Guest
-
Module naming: Boolean::Verbose
Hi, All. I have a module which I want to upload to CPAN. My calliing it Boolean::Verbose, but Boolean is to be top level. So I want to avoid... -
Module naming conundrum
Greetings, all. I have three modules I am preparing for submission to CPAN, but I freely confess that I can't come up with decent names for them. ... -
Request for naming help (templating module)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all, I have recently written a templating module and released it to CPAN. There are... -
Help naming a module
Hi, I'm building a module that when finished, I expect to upload to CPAN. This module communicates with a piece of stock trading software called... -
Var naming S.O.S
Hi, I am desperatly trying ton use concatenation in variables naming. Say i have : var nb = 5; I would like to use the value of nb in a...



Reply With Quote

