bschmer has asked for the wisdom of the Perl Monks concerning the following question:
This is all well and good, but it requires me to be in the directory where checkem.pm lives or to hardcode the path to checkem.pm in the -I argument. Neither of these is horribly appealing to me. It would be really nice if I could use the same code in each module. I was trying to do something more like:#!/bin/sh eval "exec /usr/software/bin/perl5.8.0 -I`pwd` -Mcheckem -e main $*" if $running_under_some_shell; package main; sub main { print "Hello from main\n"; <useful code here> }
but of course Perl doesn't like the DIR= and BASE=lines. Adding if $running_under_some_shell to the DIR= and BASE= lines doesn't help either and -w didn't provide any useful insight. Any suggestions would be appreciated. It would also be nice if I didn't have to name things module.pm too ;-)#!/bin/sh DIR=`dirname $0` BASE=`basename $0 | sed -e 's/\.pm\$//'` eval "exec /usr/software/bin/perl5.8.0 -I$DIR -M$BASE -e main $*" if $running_under_some_shell; package main; ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running a module?
by abell (Chaplain) on Sep 19, 2003 at 14:16 UTC | |
|
Re: Running a module?
by Abigail-II (Bishop) on Sep 19, 2003 at 14:21 UTC | |
by bschmer (Friar) on Sep 19, 2003 at 15:11 UTC | |
by BUU (Prior) on Sep 19, 2003 at 18:27 UTC | |
by Abigail-II (Bishop) on Sep 20, 2003 at 00:12 UTC | |
|
Re: Running a module?
by dtr (Scribe) on Sep 19, 2003 at 14:23 UTC |