The people who tell you to use strict etc really do have your best interests at heart, even though it may seem like they're trying to score off you without answering your question. It's like if you saw somebody climbing up the outside of a house and he calls out

"can you throw me up a hatchet so I can cut away this bunch of ivy that's getting in my way" ...

you might well say,

"hey, no, come down here, and then go inside and you'll find there's a staircase that will take you where you want to go".

(Also, if you'd seen a lot of people climbing the outside of the building and falling off and eventually going into the staircase, you might get a bit short with them.)

As to specific problems with the above, I would think particle is correct - and indeed you do it "right" in your line 2, where you have ${"NEW_BUS_TXT$x"}.

But I say ' "right" ' rather than 'right' advisedly. The Camel says of symbolic references, which is what you're doing, "very powerful, and slightly dangerous". And I think in this case you probably don't need the power, and you certainly don't need the danger.

I haven't quite figured out exactly what you are trying to achieve, but I guess you have somewhere a lot of defined variables called things like $NEW_PD1, $NEW_PD2, each of which is the html for a pull down menu.

Now the first thing I'd say is that if that's correct you would in general be far better off putting those values an array, and iterating through the array.

BUT... in this specific instance what I would really recommend would be using CGI.pm.

As you may know, this industry-standard module has lots of great functions which, inter alia allow you to generate pull down menus (popup_menu()) on the fly.

Without knowing more about what you want to put into these menus, I can't give you any example code that will be any use; but I am quite certain that using CGI in this way would save you a lot of trouble. Even if you've never used this module before (even if you've never used any module before) you would find that it repays your effort in learning to get it working.

Take a look in http://cpan.valueclick.com/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/CGI/CGI.pm-2.80.tar.gz to see the documented code, or use Super Search here to find resources to help you do this if needs be.

It wd be very interesting to see what you produce if you decide to go this way, and monks will be delighted to help you perfect it, I doubt not.

§ George Sherston

In reply to Re: Really need help with loop variable by George_Sherston
in thread Really need help with loop variable by cal

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.