[Melbourne-pm] CGI quirks and other lightweight web-tools

Mathew Robertson mathew.blair.robertson at gmail.com
Thu Jan 8 14:44:12 PST 2015


Hi PM,

In the thread discussing CGI, mod-perl and other frameworks, I thought it
might be worth discussing the good/bad points of CGI, and/or other
lightweight web-tools.  Am interested in other peoples thoughts.

Generally speaking whenever I use a framework, in particular
web-frameworks, they dramatically simplify about 80% of the workload - at
the expense of making the last 20% near-impossible to work around.

eg:
- Catalyst about 5 yrs ago, was pretty good for its time at integrating
database I/O - unless you had a table with a multi-column primary key.
- Anything with Java Spring - yay for a few lines of code to handle CRUD;
boo for knowing which config/xml file to modify just to set it up first time
- Java Hibernate v2 and v3 - again multi-column primary keys.

As such, my gut-feel is that "there be dragons whenever a framework is
used".
On the other hand "Libraries are awesome".


A similar discussion has taken place around bless() vs using Moose, et al.


So stepping back to learn from what we know... and since CGI.pm started
this discussion...

Good bits :
-  param(), url_param(), cookie()

Bad bits:
-  param and url_param ... why isn't there a way to get all params...
- it would be nice if CGI could work a little nicer with Getopt::Long so
that in non-GATEWAY_INTERFACE mode, it would use command-line arguments
 [... sounds like a useful module idea ! ]
- the whole "html shortcuts" thing.


Other people's thoughts on CGI.pm?
What other "basic tools" really help you get your work done?

cheers,
Mathew



eg: I have this that I load up in almost every bit of code that I write, so
that it gives me some (more!) globals, and sets $0 to be "$perl_script"
(instead of "perl $perl_script").... Obviously doing this everywhere comes
with a start-up cost.

package Lib;
BEGIN {
  $TIME0 = [gettimeofday];
  $BASENAME = basename($0);
  $BASEPATH = abs_path(dirname($0)) || "";
  $BASEPATH = '/' unless (length $BASEPATH);
  $FULLNAME = $0 =~ /^\// ? $0 : ($ENV{PWD} ? $ENV{PWD}."/".$0 : $0);
  $FULLNAME = canonpath($FULLNAME) || "";
  while ($FULLNAME =~ /\.\./) {
    $FULLNAME =~ s/\/?[^\/]*?\/\.\.//;
  }
  $DIRNAME = "".$FULLNAME;
  $DIRNAME =~ s/\/$BASENAME$//;
  $DIRNAME = '/' unless (length $DIRNAME);
  if (!$ENV{GATEWAY_INTERFACE} && !$ENV{MOD_PERL}) {
    lib->import($BASEPATH);
    $0 = "$BASEPATH/$BASENAME".(@ARGV == 0 ? "" : " ".join(" ", at ARGV));
    eval {
      require Sys::Prctl;
      Sys::Prctl::prctl_name($BASENAME);
    };
  }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20150109/4e949050/attachment.html>


More information about the Melbourne-pm mailing list