Ask a Question related to PERL Modules, Design and Development.
-
psyshrike #1
CGI scripts and modular design?
Howdy,
I've been poking through some different shopping cart software, trying
to decide which one to use. All of them use piped filehandles or
backticks to handle modularization.
I will be modifying my store with some very custom requirements. It
will be about a dozen modules before it is complete.
My question is, Is there are reason why CGI scripts don't:
use lib "./lib" ;
and use modular code instead of backticking everything? My virtual
hosting ISP permits calling locally installed libraries. Is it common
practice for ISP's to not allow this? If I use modular design am I
hurting my portability if I decide to go with another webhosting
service?
I have the hardest darned time sorting through the bazillion scripts
in my cgi-bin. If I can't come up with a reason not to, I am turning
half of them into object libraries, and sticking them in /cgi-bin/lib
The only reason I can think of for not doing this is executable size.
If memory is quota'd this could be a problem. The quota would have to
be pretty anemic to be a factor though.
Comments? Recomendations?
Can other folks confirm that they do this too?
-Thanks in advance
-Matt
psyshrike Guest
-
CS: Scripts do not appear in Scripts menu
I have several utility AppleScripts that I created for Illustrator 10. I'd like to use these in CS, and they work correctly when I choose "Browse"... -
Modular Text into Projector
This is probably something simple, but I can't seem to make it work. I want to be able to create a Shockwave project that will end up being a CD... -
Modular Photoshop?
Maybe this topic should be in the request section, but I think here it will get more attention and probably this suggestion is too dumb as I don't... -
Modular design using ASP
Mike, I don't follow this exactly. In your third paragraph, what is a concrete example of what you can do with PHP but not ASP? Paul "Mike"... -
Ideas for a modular config file?
Hi folk, Right now I have a project that has a "bind-style" config file that is parsed with the aid of flex and bison. It looks a bit like this:... -
Matt S Trout #2
Re: CGI scripts and modular design?
In article <79485f9d.0409280741.340cba6b@posting.google.com >,
psyshrike <shrike@cyberspace.org> wrote:Possibly, if their webserver is configured to execute scripts with an absolute>Howdy,
>
>I've been poking through some different shopping cart software, trying
>to decide which one to use. All of them use piped filehandles or
>backticks to handle modularization.
>
>I will be modifying my store with some very custom requirements. It
>will be about a dozen modules before it is complete.
>
>My question is, Is there are reason why CGI scripts don't:
>
>use lib "./lib" ;
>
>and use modular code instead of backticking everything? My virtual
>hosting ISP permits calling locally installed libraries. Is it common
>practice for ISP's to not allow this? If I use modular design am I
>hurting my portability if I decide to go with another webhosting
>service?
path.
No, definitely do this.>I have the hardest darned time sorting through the bazillion scripts
>in my cgi-bin. If I can't come up with a reason not to, I am turning
>half of them into object libraries, and sticking them in /cgi-bin/lib
Try at the top of your scripts ->Comments? Recomendations?
BEGIN {
$location = $ENV{'SCRIPT_FILENAME'};
$location =~ s!/[^/]+$!! || $location = '.';
unshift(@INC,"${location}/lib");
};
That seems to cater nicely for such things - if you're called with an absolute
path it'll push <path>/lib into the include list, if not it'll add './lib'.
Also, because it does an unshift on @INC you'll get modules in your lib before
ones in the main perl tree, which means you can "upgrade" stuff by copying your
own version in, at least for pure perl modules.
--
Today's proposed addition to the PDP-11 instruction set:
EPI Execute Programmer Immediately
Today's fatal mistake:
#include <pi-syspkt.h> [ My homepage is [url]http://www.trout.me.uk[/url] ]
Matt S Trout Guest
-
Gunnar Hjalmarsson #3
Re: CGI scripts and modular design?
psyshrike wrote:
The authors learned Perl 10 years ago?> My question is, Is there are reason why CGI scripts don't:
>
> use lib "./lib" ;
>
> and use modular code instead of backticking everything?
What you say is of course not true for all CGI scripts. There is no
reason for you to not apply Perl 5 style and incorporate code via modules.
--
Gunnar Hjalmarsson
Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
Gunnar Hjalmarsson Guest
-
John Bokma #4
Re: CGI scripts and modular design?
[email]shrike@cyberspace.org[/email] (psyshrike) wrote in
news:79485f9d.0409280741.340cba6b@posting.google.c om:
What is . ? I remember that there was (is?) no guarantee that it's the> Howdy,
>
> I've been poking through some different shopping cart software, trying
> to decide which one to use. All of them use piped filehandles or
> backticks to handle modularization.
>
> I will be modifying my store with some very custom requirements. It
> will be about a dozen modules before it is complete.
>
> My question is, Is there are reason why CGI scripts don't:
>
> use lib "./lib" ;
cwd of your script. You can use FindBin to solve this problem though.
Some don't give shell access.> and use modular code instead of backticking everything? My virtual
> hosting ISP permits calling locally installed libraries. Is it common
> practice for ISP's to not allow this?
There is so much choice in webhosting those days that it's not that> If I use modular design am I
> hurting my portability if I decide to go with another webhosting
> service?
difficult to find one that meets your requirements.
--
John MexIT: [url]http://johnbokma.com/mexit/[/url]
personal page: [url]http://johnbokma.com/[/url]
Experienced programmer available: [url]http://castleamber.com/[/url]
Happy Customers: [url]http://castleamber.com/testimonials.html[/url]
John Bokma Guest
-
Scott W Gifford #5
Re: CGI scripts and modular design?
[email]shrike@cyberspace.org[/email] (psyshrike) writes:
[...]
Sticking them in cgi-bin/lib might make them directly executable,> I have the hardest darned time sorting through the bazillion scripts
> in my cgi-bin. If I can't come up with a reason not to, I am turning
> half of them into object libraries, and sticking them in /cgi-bin/lib
depending on Web server configuration, which may not be what you want
(especially if including the file has side-effects).
I usually create a cgi-lib directory outside of the Web server's root,
and put all CGI libraries in there. That way they can't be read or
executed directly by the Web server.
I sometimes also set the PERL5LIB environment variable in Apache to
specify where my libraries are, then use this code to untaint it and
pull it in:
BEGIN {
if ($ENV{PERL5LIB} and $ENV{PERL5LIB} =~ /^(.*)$/)
{
# Blindly untaint. Taintchecking is to protect from Web data;
# the environment is under our control.
eval "use lib '$_';"
foreach (reverse split(/:/,$1));
}
}
That makes it easier to use the same script in different locations, by
just changing the Apache config (with .htaccess if you don't control
the entire server).
Overall, this is a very good idea. It should make your code easier to
maintain, encourage you to re-use code, and ensure that when you fix a
bug in one place it is fixed everywhere.
-----ScottG.
Scott W Gifford Guest
-
Gunnar Hjalmarsson #6
Re: CGI scripts and modular design?
John Bokma wrote:
Assuming we are talking about pure Perl modules, why would you need>>> My virtual hosting ISP permits calling locally installed
>> libraries. Is it common practice for ISP's to not allow this?
> Some don't give shell access.
shell access to upload them to a local library?
Possible providers who permit that you run your own CGI scripts
written in Perl, but don't 'permit' the use of own modules, are
ignorant and not worth to take into consideration.
--
Gunnar Hjalmarsson
Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
Gunnar Hjalmarsson Guest
-
John Bokma #7
Re: CGI scripts and modular design?
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in news:2rttfiF1e66a7U1@uni-
berlin.de:
make? Unless you have exact the same environment as your hosting provider.> John Bokma wrote:>>>>>> My virtual hosting ISP permits calling locally installed
>>> libraries. Is it common practice for ISP's to not allow this?
>> Some don't give shell access.
> Assuming we are talking about pure Perl modules, why would you need
> shell access to upload them to a local library?
There was a time I developed stuff on IRIX :-D
Sometimes you can get a "shell" via CGI :-D, but I prefer the real thing.> Possible providers who permit that you run your own CGI scripts
> written in Perl, but don't 'permit' the use of own modules, are
> ignorant and not worth to take into consideration.
--
John MexIT: [url]http://johnbokma.com/mexit/[/url]
personal page: [url]http://johnbokma.com/[/url]
Experienced programmer available: [url]http://castleamber.com/[/url]
Happy Customers: [url]http://castleamber.com/testimonials.html[/url]
John Bokma Guest
-
Gunnar Hjalmarsson #8
Re: CGI scripts and modular design?
John Bokma wrote:
Okay, but make isn't necessary. Simply uploading the .pm files to the> Gunnar Hjalmarsson wrote:>>> John Bokma wrote:>>>>> Some don't give shell access.
>> Assuming we are talking about pure Perl modules, why would you
>> need shell access to upload them to a local library?
> make?
right directories is sufficient. I did that successfully for several
years as long as I had a hosting account without shell access.
--
Gunnar Hjalmarsson
Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
Gunnar Hjalmarsson Guest
-
John Bokma #9
Re: CGI scripts and modular design?
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in news:2ru3msF1eom8pU1@uni-
berlin.de:
If it's pure Perl, ok. But when you need a C compiler... And let's hope you> John Bokma wrote:>>> Gunnar Hjalmarsson wrote:>>>>> John Bokma wrote:
>>>> Some don't give shell access.
>>>
>>> Assuming we are talking about pure Perl modules, why would you
>>> need shell access to upload them to a local library?
>> make?
> Okay, but make isn't necessary. Simply uploading the .pm files to the
> right directories is sufficient. I did that successfully for several
> years as long as I had a hosting account without shell access.
can access that one. Otherwise you need access to the same OS, or worse
depending on how you link.
--
John MexIT: [url]http://johnbokma.com/mexit/[/url]
personal page: [url]http://johnbokma.com/[/url]
Experienced programmer available: [url]http://castleamber.com/[/url]
Happy Customers: [url]http://castleamber.com/testimonials.html[/url]
John Bokma Guest



Reply With Quote

