473,396 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Counters in variable names.

My HTML reads a file and writes out field names to include a counter so I have fields like

<input type=text name=surname$counter><input type=checkbox name=update$counter>

When they click update these fields are sent to the update program for update.

If the person changes this field they will also tick the change checkbox and I want to be able to loop through all the fields and update them as below

UPDATE Program
for($counter=0 ; $counter < $totalrecords ; $counter++)
{
if ($update$counter)
{ blah blah}

The problem is that Perl does not seem to like me adding a variable ($counter) to a variable name ($update) and the only other way would be long winded like
if ($update1) {Blah Blah}
if ($update2) {Blah Blah}

How can I get a variable to be part of anothers variable name.

G
Jul 19 '05 #1
2 3441
dw

"Gary" <re*****@netlink.info> wrote in message
news:W8r7c.12945$1e1.1473@lakeread06...
My HTML reads a file and writes out field names to include a counter so I have fields like
<input type=text name=surname$counter><input type=checkbox name=update$counter>
When they click update these fields are sent to the update program for update.
If the person changes this field they will also tick the change checkbox and I want to be able to loop through all the fields and update them as
below
UPDATE Program
for($counter=0 ; $counter < $totalrecords ; $counter++)
{
if ($update$counter)
{ blah blah}

The problem is that Perl does not seem to like me adding a variable ($counter) to a variable name ($update) and the only other way would be long
winded likeif ($update1) {Blah Blah}
if ($update2) {Blah Blah}

How can I get a variable to be part of anothers variable name.

G


how about using something like:
${"update$counter"}

however, I assume that you are using CGI.pm and can use something like:
$q->param("update$counter")
or stuff the values into a hash:
$update{$counter} = $q->param("update$counter")
Jul 19 '05 #2
"dw" <me@verizon.invalid> wrote in message news:<GB*******************@nwrddc01.gnilink.net>. ..
"Gary" <re*****@netlink.info> wrote in message
news:W8r7c.12945$1e1.1473@lakeread06...
How can I get a variable to be part of anothers variable name.

how about using something like:
${"update$counter"}


I am less rabid than some about these things but I really don't think
that showing the OP how to write a symref is a kind thing to do. You
can tell him that symbolic references are what he's talking about but
make him go RTFM to find out about symrefs and why he doesn't really
want them.

Since the OP is asking FAQ "How can I use a variable as a variable
name?" then the best and _most_ _helpful_ response is RTFFAQ. It is,
really. Some people will disagree with me on this, but that's
because they are wrong.

This newsgroup does not exist (see FAQ). Please do not follow-up here
without mentioning this.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Carlos | last post by:
I'm responsible for the content in a call center's intranet site. There are approximately 600 pages on 7 sub-webs. I have access to the sub-webs, but I don't have access to the root web or web...
1
by: Jim Heavey | last post by:
I am messing around with performance counters to try to learn how to work with them. In VS.Net, I can see that there exist a Performance Counter with a "CategoryName" of "Browser". My...
4
by: Chad Myers | last post by:
I'm instrumenting my app with a few performance counters and I'd like to ask you all for some advice on how to handle performance counter instances. I have a class library that is a base library...
0
by: Christopher Attard | last post by:
Hi, I need to create a dialog like the 'Add Counters' dialog box in perfmon. I'm using the System.Diagnostics namespace class in .NET and I've managed to do it. The problem arises when I'm...
0
by: Christopher Attard | last post by:
Hi, I want to make use of the Performance Counter "Connections active" which falls under the "TCP" Performance object. I'm using the following code (in C#) to get the performance counter: ...
4
by: Dmitry Duginov | last post by:
I'm running some ASP.NET applications on Windows 2003 server and I cannot get ANY performance counters values in ASP.NET, ASP.NET Applications categories. Every sample is 0, application instances...
7
by: James | last post by:
Hi Has anybody had any experience of ASP.Net performance counters not updating. In the performance monitor application when I try to add the groups ASP.NET and ASP.NET Applications the...
2
by: Spam Catcher | last post by:
Has anyone else noticed that with mixed instance counters... the instance name is lowercase? Is there a way to resolve this? Thanks!
1
by: Ben | last post by:
Hi, I registered some custom perf counters that i want to use in my app (all of type NumberOfItems32). I added them under the same category name but different counter names... Same code work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.