TPM: Perl execution method question
Sam Hart
hart at physics.arizona.edu
Tue Mar 4 18:40:24 CST 2003
> Out of curiousity, why do you need a single script to do all of this?
> Wouldn't it be easier to make several? If there is a lot of common code
> you could put it in another file and require it from the seperate files.
Because I haven't yet decided what final interfaces I want for the script,
so I really don't want to lock anything down just yet. Plus, it will make
it easier to install and set-up.
(In case you're curious, I've got a little news/blogging script I've used
for a while over at tux4kids, and I'm trying to make it easier for our
developers to submit messages to it... ie they can use the web if
desired, or CC this script their general news announcements they already
email, etc. By doing this, then I don't have the be the PR person in
addition to all my other duties ;-)
> One could also make aliases/links of the same file to different names and
> then check to see the invoked name of the script. $0 or something of
> that nature...
>
> For example:
> ----------------------------------------------
> % touch actual_script.pl
> % ln -s actual_script.pl cgi-version
> % ln -s actual_script.pl mail-version
> % vi actual_script.pl
> #!/usr/bin/perl
>
> if( $0 eq 'cgi-version' ) {
>
> # do cgi-stuff here...
>
> } elsif( $0 eq 'mail-version' ) {
>
> # do mail stuff here
>
> } else {
>
> # Do debugging or error stuff here
>
> }
> ----------------------------------------------
>
> Hope this helps,
Actually, yes, this does. This would work perfectly plus it would allow
for addition of new interfaces as needed. Dunno why I didn't think of
that... Guess it's one of those forest for the trees kind of things ;-)
--
Sam Hart
University/Work addr. <hart at physics.arizona.edu>
Personal addr. <criswell at geekcomix.com>
end
More information about the Tucson-pm
mailing list