CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Adding variable to existing variable

 



devonbosch
New User

Mar 8, 2007, 4:00 AM

Post #1 of 4 (467 views)
Adding variable to existing variable Can't Post

I have sendind data from a form to this sub. The data consist of many rooms, which is selected by a drop-down box. I've tried $fields{'rtqty$count'} asswell, but nothing seems to work. Please help... $count = 1; if ($fields{'rtqty'} .$count ne "")
{
while ($count <= $fields{'rtqty'} . $count)
{
$rooms = $rooms . "Room: $fields{'name'} . $count<br>";
$count ++;
} }


KevinR
Veteran


Mar 8, 2007, 9:04 AM

Post #2 of 4 (465 views)
Re: [devonbosch] Adding variable to existing variable [In reply to] Can't Post

I don't understand your question.
-------------------------------------------------


rheydenr
Novice

Mar 14, 2007, 2:56 AM

Post #3 of 4 (458 views)
Re: [devonbosch] Adding variable to existing variable [In reply to] Can't Post

Hi devonbosch,
you can try $fields{"rtqty$count"} (with double quotes!). This should work.
A construct like $fields{'rtqty'} . $count won't work as expected, since it concatenates the values as string. Perhaps it works with eval, but the upper proposal should be better.

HTH,
Ralf.


devonbosch
New User

Mar 14, 2007, 5:03 AM

Post #4 of 4 (454 views)
Re: [rheydenr] Adding variable to existing variable [In reply to] Can't Post

Thanks for your reply. I found the solution throught trial and error. This is what I have done:

Code
 while 
{
$rtidt = rtqty . "$nr";

$rtid2 = $fields{$rtidt};
$nr ++;




}



(This post was edited by devonbosch on Mar 14, 2007, 5:06 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives