[Canberra-pm] do read-local.config

Michael James Michael.James at csiro.au
Wed Mar 29 22:20:59 PST 2006


On Thu, 30 Mar 2006 04:43 pm, Andrew Pollock wrote:
> On Thu, Mar 30, 2006 at 01:21:27PM +1100, Michael James wrote:
> > In the perl cookbook it suggests a good way to keep
> >  local configuration details out of a larger and messier script
> >  is to put normal perl code into a separate file and  "do"  it.
> > 
> > But in a throwaway line (middle of page 328) it says,
> >  of course neither the doer nor the done will have access
> >  to the other's lexical (my) variables.
> >  
> > Hang ON! Lets get this clear,  the  done.config  file
> >  can't create a variable visible to the calling program,
> >  nor see a pre-existing variable to change it.
> > 
> > What's the point?
> > 
> > Can any of you lexicographers explain
> >  a way around this, to a bear of limited scope?
> 
> Reading the output of a perldoc -f do,  it doesn't say anything
> about the variables defined in the file being "done"
> not being visible to the caller,  but I could imagine
> anything declared with "my" wouldn't be visible,
> so just don't use "my" in the config file being "done"?

Some experimentation shows how it used to work:

ONLY if neither doer nor done  "use strict;",
 AND the variable doesn't already exist,
 does the value from "done" appear in "doer".

Not satisfying, I don't mind living without strict
 in the config file, but want it in the main program.

I also want to use this for a CGI script to call another perl program
 without passing heaps of user supplied info on the command line.
In the past I've done this by writing it all into a configuration file
 and passing that, but it's more of a pain
 than saying  "do second-half.pl".

-- 
Michael James                         michael.james at csiro.au
System Administrator                    voice:  02 6246 5040
CSIRO Bioinformatics Facility             fax:  02 6246 5166

No matter how much you pay for software,
 you always get less than you hoped.
Unless you pay nothing, then you get more.


More information about the Canberra-pm mailing list