chickenman has asked for the wisdom of the Perl Monks concerning the following question:
i'm facing a Problem and i'm not able to google the answer. The Problem is that i'm even not sure about what to search..
Let me try to explain. I've a variable which contains another variable which value changes after it has been stored in the second variable.
E.g.The expected output ismy $a = ''; my $str = "Hello ".$a; $a = 'Kevin'; print $str;
Hello Kevin
I'm not sure how to achieve this.
Thank you in advance.
### EDIT ####It is only about readability.
I've created a Perl Package which delivers all default values for the Program context
Some of these values are relaing on variables which will be updated during runtime.
Like my $executable = "$homedir/bin/abc"; And $homedir will be found within the perl Code.Of course i could move this variable into a subroutine and read it once $homedir has been set.
But in the same context there are variables which have been changed and i don't won't to overwrite them again.
The only solution i can think of is to split the static variables and the dynamic ones into different subroutines.
I thought there might be an option to evaluate the variable value when accessing it for the first time.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Evaluate variable while using
by hippo (Archbishop) on Oct 21, 2022 at 11:34 UTC | |
Re: Evaluate variable while using
by choroba (Cardinal) on Oct 21, 2022 at 12:22 UTC | |
Re: Evaluate variable while using
by bliako (Abbot) on Oct 21, 2022 at 13:22 UTC | |
Re: Evaluate variable while using
by bliako (Abbot) on Oct 21, 2022 at 12:42 UTC | |
Re: Evaluate variable while using
by tobyink (Canon) on Oct 21, 2022 at 12:42 UTC | |
Re: Evaluate variable while using
by GrandFather (Saint) on Oct 21, 2022 at 11:35 UTC | |
Re: Evaluate variable while using
by Fletch (Bishop) on Oct 21, 2022 at 11:51 UTC | |
Re: Evaluate variable while using
by BillKSmith (Monsignor) on Oct 21, 2022 at 15:55 UTC | |
Re: Evaluate variable while using
by afoken (Chancellor) on Oct 21, 2022 at 16:22 UTC | |
Re: Evaluate variable while using
by sectokia (Friar) on Oct 21, 2022 at 13:36 UTC | |
by chickenman (Novice) on Oct 21, 2022 at 14:00 UTC | |
by haukex (Archbishop) on Oct 21, 2022 at 14:06 UTC | |
Re: Evaluate variable while using
by jo37 (Curate) on Oct 21, 2022 at 18:23 UTC |