Hello wise monks,
This is my first question to the monastery, although I've been silently lurking here for a while...
Anyway. I am reading (from a configuration file) a list of expressions to evaluate.
I am reading these into a hash where the hash key may be one of the variable in the expression it associated to or may not.
The configuration file looks like this
x ++$x y int(((log10 ($x/100 + 1)) + 3)*100) z $x+$y+$z
and so the hash turns out like this:
$function_hash{"x"}="++$x"; $function_hash{"y"}="int(((log10 ($x/100 + 1)) + 3)*100)"; $function_hash{"z"}="$x+$y+$z";
Now, I am getting values for the variable through a proprietary communication protocol (which is,btw, the real complicated part of that program, but it's not relevant now).
So I'm ending up with another hash that have:
$value_hash{"x"} = 10; $value_hash{"z"} = 30;
It may or may not contain all the variables I have functions for.
I am using the module Alias to turn all the field names in the value hash into local variables (with attr) and then I am doing eval on the entries in the %function_hash to get what I need.
It works nice except for those warnings "Use of uninitialized value..." which happens since I use strict.
I cannot use vars with the variables I have in the value hash since I know them only at run time (from the config file).
I don't want to use something like:
$Alias::AttrPrefix = "main::";
since then the functions in the configuration will need to be written differently or go through some parsing I don't want to do...
Please help (and I want to go on using strict...)
Thanks in advanced!!

In reply to A question about Alias module and use strict by Anonymous Monk

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.