[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: clone and overrides
From: |
Steven Knight |
Subject: |
Re: clone and overrides |
Date: |
Sat, 20 Oct 2001 17:51:39 -0500 (CDT) |
> I'm trying to create a new cons environment from an existing one, and
> modify some of the variables. I tried the following:
>
> $vm_ta_env = $vm_env->clone(
> CFLAGS => '-DMISSIONPACK ' . $CFLAGS
> );
The above would expand the *Perl* variable $CFLAGS, not the environment
construction variable %CFLAGS. Hence, nothing gets appended. *If*
clone() expanded construction variables, the way to do it would be:
$vm_ta_env = $vm_env->clone(
CFLAGS => '-DMISSIONPACK %CFLAGS'
);
But clone() doesn't expand construction variables...
> I end up with a $CFLAGS that only holds '-DMISSIONPACK ', I had to find
> another way to get what I wanted:
>
> %vm_ta_env_hash = $vm_env->copy();
> $vm_ta_env_hash{CFLAGS} = '-DMISSIONPACK ' . $vm_ta_env_hash{CFLAGS};
> $vm_ta_env = new cons(%vm_ta_env_hash);
Here's a slightly less roundabout way to do what you want; fetch the
CFLAGS construction variable explicitly:
$vm_ta_env = $vm_env->clone(
CFLAGS => '-DMISSIONPACK ' . $vm_env->{CFLAGS},
);
> Is there a reason why the clone() command doesn't override correctly? Or
> is it a bug?
It overrides "correctly," it's just never been defined to expand
construction variables within the overridden values. That would be an
attractive enhancement.
--SK