>>Any pointers to reading lucid descriptions of dealing
>>with variable variables in perl would be greatly appreciated.

>In short, you don't.

why not? Because it is bad? Because it is bad style? Because it will lead to unexpected results? I don't mean to be argumentative, but just telling me I shouldn't is not satifying.

>Why is it that so many people want to
>use symbolic references in Perl (because that's what it is)?
>You don't have symbolic references in C. You don't have
>symbolic references in Java. You don't have symbolic
>references in many, many languages. And I don't get the
>impression people programming in Java or C regulary ask
>how to get the name of a variable, or how to use a value
>as a variable.

I know nothing about C and Java so I have no idea what those users do. However, I can think of various uses for such a facility. Suppose I have a choice of actions I can pick from

$action can be 'dothis' or 'dothat' or 'dosomethingelse'

And I want to run the functions dothis() or dothat() or dosomething() based on the action picked. I can use the following code --
&dothis if ($action eq 'dothis'); &dothat if ($action eq 'dothat'); &dosomethingelse if ($action eq 'dosomethingelse');
or I could just
&$action;
but I can't because that is not allowed under use strict; so I
eval($action);
and that works and is a lot shorter than the series of if statements. Imagine if I had a lot of choices for action -- that would be a lot of if statements.

Well, this is just one example.

>>what if the var was a var?
>What else could a var be than a var

Sorry, my bad. I meant, what if the var name was varying and I wanted to do something based on its name.

Anyway, thanks for the advice. I'll think of better ways to write my code.

In reply to Re: Re: another 'array to hash' question by punkish
in thread another 'array to hash' question by punkish

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.