It sounds like the eval solution proposed earlier is exactly what you're
looking for then.  You can just store the string in your hash and eval it
when you need to print.

-----Original Message-----
From: Tim Yohn [mailto:tyohn@;alabanza.com]
Sent: Thursday, November 07, 2002 10:54 AM
To: Timothy Johnson
Cc: [EMAIL PROTECTED]
Subject: Re: Population of variables in hash values...


On Thu, 7 Nov 2002 10:35:22 -0800 
Timothy Johnson <[EMAIL PROTECTED]> wrote:

> 
> Then I guess the real question is why you are declaring two variables
> that you want to be concurrently updated when you can just use one.
> 

Obviously I must not be able to explain what I am trying to
accomplish...  I am trying to update the value of the hash without
having to redefine the hash... the example was just that, a very
simplistic example and had no real purpose for existence other than for
me to not have to explain the full code.   Since my simple example
wasn't complex enough to understand why I would want to do it that way
the full example the hash is actually as follows:

%error = (
        1  => "Cert and Key locations must be specified",
        2  => "Username must be supplied via the -u command line flag",
        3  => "Must specifiy an action to take",
        10 => "Internal script error during add, please report",
        11 => "Home directory is not a directory or link",
        12 => "Verification of certificate failed, please check
certificate for validity",
        13 => "Verification of key failed, please check key for
validity",
        14 => "Certificate modulus and Key modulus blocks do not match,
please check to make sure the correct certificate and key are being
used",
        15 => "Specified cert does not exist: ".$cert,
        16 => "Specified key does not exist: ".$key,
        17 => "Could not fork ".$certcmd." to validate cert: ".$!,
        18 => "Could not fork ".$keycmd." to validate key: ".$!,
        19 => "Creation of ".$certpath." failed: ".$!,
        20 => "Installation of Certificate as
".$certpath."/".$domain.".crt failed",
        21 => "Creation of ".$keypath." failed: ".$!,
        22 => "Installation of RSA Private key as
".$keypath."/".$domain.".key failed"
); 

Now this is declared at the beginning of the script and depending on
where it is called the variables that I defined in there may contain
different values from when the hash was defined ... for example $keypath
may be /etc/mail/private or it may be /usr/local/ssl/private... I would
prefer not to have to duplicate tons of error messages just because one
variable has changed (and what happens if later we want to install keys
in /usr/bob/keys/private/blah/blah/blah, another error message would
have to be created).  I'm looking for a way to be able to populate the
variables contained in the hash on the fly instead of when the hash was
defined.

Thanks,
Tim.

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

Reply via email to