Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic variables

Status
Not open for further replies.

antdickens

Programmer
Nov 13, 2001
129
GB
Is there a way to nake a variable so that part of it can be changed. For example i am creating a form with data from a text file.
There are 40 lines of data so ideally i would like to say

start loop
counter = counter ++
price(counter) = x
next

then the values which i have specified in a block of html which is sent to the browser, ie

$price1,$price2

will have the values gained from the loop. Any ideas
 
Sounds like you want a hash. Here's an example:

%Price = (
bread => '1.99',
eggs => '1.54',
milk => '2.39',
);

foreach $Item (sort keys %Price) {
print "The price of $Item is \$$Price{$Item}\n";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top