Dear Monks,

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.
my $a = ''; my $str = "Hello ".$a; $a = 'Kevin'; print $str;
The expected output is

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.


In reply to Evaluate variable while using by chickenman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.