I've just finished a new cross-language web developement framework
called Jasper. It supports several (four, in fact) platforms and
languages, Perl amongst them.
I am posting this new thread since I want others to have a go with
Jasper, and hopefully provide some helpful comments.
Based on a cursory look, I would stay away from this module.
You have re-written a lot of fundamental Perl functionality, which
results in obscurity and (completely unnecessary) performance penalties.
For example,
package ArrayUtils;
sub size
{
my $arr = shift;
return ( scalar @$arr );
}
or
sub keyExistsAndNonEmpty
{
my $arr = shift;
my $key = shift;
return ( exists($arr->{$key}) && !StringUtils::equals( $arr->
{$key}, "" ) );
}
The naming of this method is completely misleading. And, a simple
length $str
is enough to check if $str is empty or not.
You have basically written Java in Perl. There is a reason we program in
Perl. If I wanted to program in Java, which I still occasionally do, I
would just go ahead and program in Java.
package RegEx;
sub new
{
my $class = shift;
my $this = {};
bless ($this, $class);
my $re = shift;
my $ignore = shift;
if ( !$ignore )
{
$this->{re} = qr/$re/;
}
else
{
$this->{re} = qr/$re/i;
}
return $this;
}
sub find
{
my $this = shift;
my $line = shift;
if ( $line =~ $this->{re} )
{
my $left = $`;
my $right = $';
my $middle = $&;
my $match = $1;
my @matches = ( $middle );
for ( my $i = 1; $i <= 9; $i++ )
{
if ( my $mi = eval("\$$i") )
{
$matches[ $i ] = $mi;
};
}
return ( RegExResult->new( $left, $right, $middle, $match,
\@matches ) );
}
return ( undef );
}
Once again, you have obscured a whole bunch of crucial things going on,
introduced a completely unnecessary string eval, incurred unnecessary
performance penalties etc.
In other notes, you trample all over the namespace. For example, you put
stuff in package Config. You should read
perldoc perlmod
to learn how to partition the name space, and write proper modules.
There are too many hidden bugs, bad programming practices, and plain old
crap in your code to even begin to think about making it better. You are
better off deleting all existing copies, and going over to CPAN.
There are a whole bunch of great frameworks, such as Catalyst and
Maypole, or a bunch of modules such as CGI::Application, CGI:
rototype,
HTML::Template, Template.pm, Class:
BI so on and so forth for writing
web applications.
Sinan
--
A. Sinan Unur <
[email protected]>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html