On Wed, 3 Nov 2004, Gavin Henry wrote:

> Chris Devers said:
> > On Tue, 2 Nov 2004, Gavin Henry wrote:
> >
> >> What is the easiest way to move variable declarations out into a file
> >> in /etc/ and requiring a perl program to read them in at startup. If
> >> they are not there, then the program must complain.
> >
> > Have you considered using Tie::File, FreezeThaw or Data::Dumper?
> >
> >     <http://search.cpan.org/~mjd/Tie-File-0.96/lib/Tie/File.pm>
> >     <http://search.cpan.org/~ilyaz/FreezeThaw-0.43/FreezeThaw.pm>
> >     <http://search.cpan.org/~jhi/perl-5.8.0/ext/Data/Dumper/Dumper.pm>
> 
> Thanks I will try them. I think it's a bit weird I can't do this out of
> the box. Does anyone else?
 
Data::Dumper should be a core module in at least Perl 5.8.x, and it may 
have been a core module in 5.6.x (I forget). 

So if you have Perl, you've probably got at least that module.

More broadly, there is a line of thinking that core Perl should ship 
with a minimal set of modules, and that people should be in the habit of 
thinking that it's no big deal to grab something off CPAN. Because it's 
not a big deal, really, and if Perl were to ship with *everything* in 
CPAN, it would be many gigabytes -- most of which would be irrelevant to 
most people.

For this particular problem, there are several ways you could go about
writing it, and no clear "best" way, as different people with similar 
requirements may have different specific needs & constraints. For the 
most part, Python just provides one way to do this -- "pickling" data 
structures to a file when a program halts, and "unpickling" them when 
the program is invoked again. Perl's Data::Dumper can be used in about 
the same way, and FreezeThaw comes even closer to that approach. But for 
some people, that's not the way to go at all, and Perl doesn't enforce 
any one approach here (or just about anywhere else). 

 

-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to