Kevin Old wrote:
 
> I am writing a script for a client and they have requested an easy way
> to configure their script.....without having to enter the script code
> itself.


> Second, which sytax (in your opinion) should I use?
> 
> $CDMA::USER = "myusername";
> 
> or
> 
> use constant USER => "myusername";
> (called like CDMA::USER.....correct?)
> 

Personally, I quite like use constant. I've got quite a few scripts 
configured at the top with constants - data directories, that sort of thing.

The advantage over variables is that these things are obviously constants, 
and you can't go changing them in your code. It makes it easier for 
mainanance programmers to see what's going on.

If it's just a one-off script, and these variables aren't going to be 
needed by any other script you write, then throw a few constants at the top 
of the script. If you've got more complicated configuration to do, then 
check out some of the config modules off cpan - there's loads of them.

And don't underestimate the power of using perl data structures for 
configuration. Data::Dumper and eval might help you out.

--
Best Regards,
Daniel

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to