Using a for() statement to create a variable??

D

dayton

I have a form that is dynamiclly generated from a database. Using the
CGI module, I'm trying to parse the parameters returned, but since the
number of paramaters changes I can't get the variables assigned...

What I'm trying:
--------------
$count='1';
while (my(@data)=$table_data4->fetchrow_array) {
print qq|
<tr><td><input name=rs$count type=text
maxlength=7 size=7 value=$data[0]><td>$data[1]
|;
$count++;
}
--------------------

which correctly populates the table but then when I try to parse the
parms..

(like : if (param()){ $buh = param('buh') || '';}

I run into my problem. I've tried:

----------------------
for ($i=1;$i<=$number;$i++)
$R$i="rs$i";
}
----------------------

and the error I get is:

Scalar found where operator expected at ./test line 5, near "$RS$i"
(Missing operator before $i?)
syntax error at ./test line 5, near "$RS$i"
Execution of ./test aborted due to compilation errors.


How can I auto-generate the variables based on the # of params created
by the form?
 
J

Jürgen Exner

I have a form that is dynamiclly generated from a database. Using the
CGI module, I'm trying to parse the parameters returned, but since the
number of paramaters changes I can't get the variables assigned... [...]
for ($i=1;$i<=$number;$i++)
$R$i="rs$i"; [...]
How can I auto-generate the variables based on the # of params created
by the form?

You don't. Symbolic references are evil, please see the FAQ and google. This
has been discussed to death many, many times over.
Instead us a more suitable data structure like a hash. Again, the FAQ
explains how ("How can I use a variable as a variable name?").

jue
 
J

Jürgen Exner

[Full-quote]
"To do what?"

Weren't you the guy insulting me on another post....

Who is "you"? Whom are you talking to?
Usenet is a 1-to-many communications form. Do you mean every single reader
of this newsgroup?

jue
 
R

robic0

""Who is "you"? Whom are you talking to?""

JH #2 - Please speak english in clear, readable and understandable
expressions.
What are "you" talking about?
 
J

Jürgen Exner

""Who is "you"? Whom are you talking to?""

I suppose this is a quote from an article I posted. It is common courtesy to
mark quoted text as such and to provide an attribution.
JH #2 - Please speak english in clear, readable and understandable
expressions.
What are "you" talking about?

I strongly suggest that you read up on basic Nettiquette ASAP. You are on
the brink of being granted membership in many killfiles.

jue
 
R

robic0

"I suppose this is a quote from an article I posted. It is common
courtesy to
mark quoted text as such and to provide an attribution.

JH #2 - Please speak english in clear, readable and understandable
expressions.
What are "you" talking about?


I strongly suggest that you read up on basic Nettiquette ASAP. You are
on
the brink of being granted membership in many killfiles.
"

I suggest you not mention "kill" as an attribute within your reply.
Should you feel the need
to kill someone, I suggest you consult proffessional help immediatly.
In America, we do not
take kindly to threats from individuals from foreign countries. Your
time may well be better
spent mastering english and gaining insite on American culture.
 
A

A. Sinan Unur

"I suppose this is a quote from an article I posted. It is common
courtesy to mark quoted text as such and to provide an attribution.

And you have failed again to show common courtesy.
I strongly suggest that you read up on basic Nettiquette ASAP. You are
on the brink of being granted membership in many killfiles. "
Ditto.

I suggest you not mention "kill" as an attribute within your reply.

Your ignorance is amusing.

http://www.google.com/search?q=define:+killfile
Should you feel the need to kill someone,

No one said anything about killing anyone.
I suggest you consult proffessional help immediatly.

Spell check: 'professional' and 'immediately'
In America, we do not take kindly to threats from individuals from
foreign countries.

Just FYI: UseNet is not America.
Your time may well be better spent mastering english and gaining

Spell check: 'English'.
insite on American culture.

Spell check: 'insight'.

Grammer check: 'insight into American culture'.

I know, I know, I am feeding the troll.

I am going to shut up now.

Sinan.
 
J

Jürgen Exner

"I suppose this is a quote from an article I posted. It is common
courtesy to
mark quoted text as such and to provide an attribution.

Would you please start providing proper credits when quoting text that you
didn't write? Or do you want to be accused of plagiarism?
I strongly suggest that you read up on basic Nettiquette ASAP. You are
on
the brink of being granted membership in many killfiles.

Again, I never granted you the right to copy my text and to claim it as your
own.
I suggest you not mention "kill" as an attribute within your reply.
Should you feel the need
to kill someone, I suggest you consult proffessional help immediatly.

Your ignorance is surely broad. But really stunning is your resistance to
learning.
In America, we do not
take kindly to threats from individuals from foreign countries.

Yeah, true. It happens so easily that a certain person from Texas believes
you have weapons of mass destruction in your backyard....

BTW: Last time I checked America was a double continent. Which country
within (or outside of) this continent are you considering to be "foreign"?
Your
time may well be better
spent mastering english and gaining insite on American culture.

Try "English" and "insight into".
Oh, and is there such a thing as _the_ American culture? I always found
Carribean, Canadian, and Argentinian culture to be quite different.

Proud to be an old European (although living in the USA).

jue
 
J

Joe Smith

Dynamically generate the code block, then use "eval" on it?

No! That is as bad, if not worse, than symbolic references.

The message you are following up to (which you neglected to
include any part of in your message) has the correct answer.

It is quite clear that you are inexperienced in the ways of
USENET. USENET is not the same as a web forum.

When you post a follow-up message here, you are expected to
include the name of the previous poster and a selected
portion of the previous message.
 
B

Brian McCauley

(e-mail address removed) in a typical display of rudeness gives no context when
he says:

[ Of using symrefs in a loop to create several variables with numeric
suffixes ]
Dynamically generate the code block, then use "eval" on it?

It is, of course, a general rule that any inappropriate use of symrefs
can be made even worse by using eval instead of symrefs.

Symrefs and eval(STRING) are powerfull but dangerous tools. Use them
only when the beniefits outweigh the costs. Symrefs are the lesser of
the two (in both power and danger).
 
T

Tad McClellan

You are
on
the brink of being granted membership in many killfiles.

I suggest you not mention "kill" as an attribute within your reply.
Should you feel the need
to kill someone,


Pardon me but your ignorance is showing yet again.

Nobody (apart from you) has said anything about killing anyone.
 
J

John W. Kennedy

I suggest you not mention "kill" as an attribute within your reply.
Should you feel the need
to kill someone, I suggest you consult proffessional help immediatly.
In America, we do not
take kindly to threats from individuals from foreign countries. Your
time may well be better
spent mastering english and gaining insite on American culture.

Listen, you dirty little traitor. A lot of good Americans in my father's
generation gave their lives to put an end to vermin like you, and the
last thing we need is to have an infestation back home. So you can just
pack up your semiliterate, un-American shit and haul ass to North Korea,
where you'll be right at home.

--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
 
R

robic0

Listen, you dirty little traitor. A lot of good Americans in my father's
generation gave their lives to put an end to vermin like you, and the
last thing we need is to have an infestation back home. So you can just
pack up your semiliterate, un-American shit and haul ass to North Korea,
where you'll be right at home.

No problem. I'm in Los Angeles, California name a time and place so
i can meet you and your fatther
 
R

robic0

Hey, Robic0, I have to thank you for providing me with several minutes
of fun, catching up with the newsgroup this morning. Far from
killfiling you (I guess you know what that means now) I've actually
been searching the group for your posts. The technical ones aren't
very interesting: they're rather obscure and from the reactions of the
Perl mavens here I suspect they're not very accurate; but the
non-technical ones like this are a hoot.

The way you assume that Google is the same as USENET, and that the
group is a "site", and that the whole thing is in some way "owned" by
the USA and that everyone with a European or Asian name is therefore a
"foreigner" and to be deprecated in some way ... you provide more and
more fun with each thread. And the myopic pomposity you manage to get
into every post just cracks me up. Thanks.


HHHHHHEEEEEEEYYYYYYYYYYYYYY
HEEEEEEEEEEEEEEENNNNNNNRRRRRRRRYYYYYYYYY !!!!!!!!!!!!!

How the **** are ya man ?????????
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top