"John W. Krahn" <[EMAIL PROTECTED] > To Perl Beginners <beginners@perl.org> 12/19/2005 08:29 cc PM Subject Re: use constant
David Gilden wrote: > Greetings, Hello, > I looked for documentation on 'use constant' but it has eluded it me..... > > my $path = `pwd`; > use constant UPLOAD_DIR => "/home/sites/site123/web/private/_data/"; > > > I want to get the Document Root at runtime and concatenate like such... > > > my $path = `pwd`; You should probably use the Cwd module to do that. > use constant UPLOAD_DIR => "$path/_data/"; use Cwd; my $path; BEGIN { $path = cwd } use constant UPLOAD_DIR => "$path/_data/"; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> ******************************************************************** ******************************************************************** David, although there are various ways to do what John stated, the use constant is not a recomended pragma according to the Oreilly book "Perl Best Practices." Rather Readonly is a better method b/c it can be interpolated. use Readonly; my $SCALER => 'value'; use Readonly; my @ARRAY => 'value'; use Readonly; my %HASH => 'value'; for versions 5.8 and above but for versions 5.6 and below use Readonly::Scaler; my $SCALER => 'value'; Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>