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: Beginner:
anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop?

 

First page Previous page 1 2 Next page Last page  View All


rmh_va
Novice

Aug 17, 2011, 7:17 AM

Post #1 of 32 (5098 views)
anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? Can't Post

I have 8 variables passed to me in from a DBI call... I cannot change the call/process... It passes bunches of 8 variables to me... I'd like to read them in a loop, and not have to hard code the variable name...

I am not looking for coding critique, I am looking for a YES/NO answer, do you know how to interpolate in this manner?

here's the code snippet:



I have 8 variables... I would like to reference them in a loop without hard-coding the names...

$sub1 = 'var1name/var1text';

$sub2 = 'var2name/var2text';

$sub3 = 'var3name/var3text';

$sub4 = 'var4name/var1text';

$sub5 = 'var5name/var1text';

$sub6 = 'var6name/var1text';

$sub7 = 'var7name/var7text';

$sub8 = 'var8name/var8text';

print '<table>';

while ($i < 9) {

$temp = "$sub.$i";

@xr = split("/",$temp);

print '<tr><td>',$xr[0],'</td><td>',$xr[1],'';

$i++;

}

print '</table>';


this statement, $temp = "$sub.$i"; is wrong... I can't figure out the proper way to interpolate it within a loop, using the loop index as part of the interpolation...

can anyone help with this specifc statement, $temp = "$sub.$i"; ?

I am not interested or able to recode the interface, it gives me what it gives me... I need a way to iterate thru the variables, using a loop...


FishMonger
Veteran / Moderator

Aug 17, 2011, 7:29 AM

Post #2 of 32 (5097 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post


Quote
I am looking for a YES/NO answer, do you know how to interpolate in this manner?


YES


rmh_va
Novice

Aug 17, 2011, 7:33 AM

Post #3 of 32 (5093 views)
Re: [FishMonger] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

Please do not reply to this post, it asks specifically in the subject that YOU refrain from doing so...


FishMonger
Veteran / Moderator

Aug 17, 2011, 7:36 AM

Post #4 of 32 (5092 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

It's an open forum. I can post as I please.


fixles
Novice

Aug 17, 2011, 7:38 AM

Post #5 of 32 (5092 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post


In Reply To
I am not looking for coding critique, I am looking for a YES/NO answer, do you know how to interpolate in this manner?

YES

PS: I interpolate your bad manner is exceeded only by your bad manner


rmh_va
Novice

Aug 17, 2011, 7:48 AM

Post #6 of 32 (5086 views)
Re: [FishMonger] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

It ASKS that you refrain, doesn't say you must... If this makes you feel special, or important, or whatever, continue to post replies, I'll just ignore them, and wait for someone that has knowledge in the subject I've asked about to chime in....


rmh_va
Novice

Aug 17, 2011, 7:51 AM

Post #7 of 32 (5084 views)
Re: [fixles] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

 I can help you by forwarding you the name of a teacher who specializes in ESL, and specifically sentence construction... She would work with you at a reasonable rate... If interested let me know...


fixles
Novice

Aug 17, 2011, 8:01 AM

Post #8 of 32 (5082 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post


In Reply To
I can help you by forwarding you the name of a teacher who specializes in ESL, and specifically sentence construction... She would work with you at a reasonable rate... If interested let me know...


Not if she's worked worked with you. Your sentence structure is almost as bad as your bad manners.


rmh_va
Novice

Aug 17, 2011, 8:30 AM

Post #9 of 32 (5076 views)
Re: [fixles] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

 thanks for the critique, not sure if you're from Northern India, or Southern? anyway, you should consider getting help, that sentence you wrote in your first reply was a laugher... I emailed it to a bunch of friends, they all got a chuckle...


fixles
Novice

Aug 17, 2011, 8:43 AM

Post #10 of 32 (5072 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

I'm sure they were laughing at you not with you. They probably though who's the bad mannered moron annoying now. Then they all disappeared as you thought of something else (In case you didn't get it I was referring to you having imaginary friends. I find it hard to believe anyone with such poor social skills would have any real friends).

Anyway back to the topic at hand, sentence structure. Letís have a little test shall we. How many full stops (periods in America) do you add to the end of a sentence? I say one. You? Well clearly from everything you've written you think its three. Once again you are FAIL.

See how your imaginary friends like this post.

I'm from the UK how is the weather in Karachi?


rmh_va
Novice

Aug 17, 2011, 9:01 AM

Post #11 of 32 (5067 views)
Re: [fixles] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

thanks for the grammar citique, you are obvisoully a skilled wordsmith... Maybe you can parlay this skill into a money maker, so that your mom won't have to spend so much time on her knees trying to make the rent...


fixles
Novice

Aug 17, 2011, 9:12 AM

Post #12 of 32 (5064 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post


In Reply To
thanks for the grammar citique, you are obvisoully a skilled wordsmith... Maybe you can parlay this skill into a money maker, so that your mom won't have to spend so much time on her knees trying to make the rent...


No need I make all my money pimping out your mum, dad, sister and grandma. Your mum does it for free she loves it so much. I let the homeless people who live behind the seven eleven have her every Wednesday night for free. I know what youíre thinking and yes I am charitable, Just doing my bit for society.

PS: Youíre still adding too many full stops to the end of your sentences.


rmh_va
Novice

Aug 17, 2011, 9:25 AM

Post #13 of 32 (5061 views)
Re: [fixles] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

since my mum/mom, dad, and grandma are all passed, I would guess you meant only my sister, which I know isn't true, because she says you brit guys have small penises...kinda makes sense, most guys with little willies like you are prone to compensating some other way, hence your trying to convince others in here of you manlliness by tyring to be funny in a "yo' mama" type forum... maybe you should try the extenz pills or something, I hear they have "Extra Strength" for you brit guys...


fixles
Novice

Aug 17, 2011, 9:50 AM

Post #14 of 32 (5055 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

Most of your family is dead and your sister has falling for the charms of what sounds like a least a couple of Brits. Now I understand where all this misplaced anger is coming from.

Now judging the size of a races penis based on a small sample seems a little unfair. Some would even say racist. But then again just how many Brits has she slept with? Maybe she sleeps with loads of Brits to stop her thinking about her miserable life with her bad mannered annoying brother and dead parents. Who knows? Come to think of it who cares?

So run along now little boy. Try finding another forum where someone can see past your bad manners and excessive use of full stops and may be nice enough to help you. Despite my charitably manner as proven by my loaning your dead mother to the homeless I don't intend to help you.

So long and thanks for all the fish.

PS: Itís my birthday next week going out for lunch with my mum, dad, sister, grandma and granddad. It will be nice.

PPS: Bet you have a little willy and thatís why you brought it up. Your projecting just like when you mentioned my mum and yours was dead.

PPPS: Now I think of it probably best you seek professional help. Projecting your problems though this forum in an angry manner isn't the best way for you to get better.


rmh_va
Novice

Aug 17, 2011, 10:08 AM

Post #15 of 32 (5051 views)
Re: [fixles] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

please ignore the replies before, some gay guy from the U.K.... he sent me all kinds of personal replies, even after I told him I'm not gay/interested, he wouldn't stop... pretty sick stuff... if any of you get replies from this guy, delete them, they're not worth opening...



I orignially asked if anyone knows how to fix my interpolation problem...



here's the code...



I have 8 variables... I would like to reference them in a loop without hard-coding the names...

$sub1 = 'var1name/var1text';

$sub2 = 'var2name/var2text';

$sub3 = 'var3name/var3text';

$sub4 = 'var4name/var1text';

$sub5 = 'var5name/var1text';

$sub6 = 'var6name/var1text';

$sub7 = 'var7name/var7text';

$sub8 = 'var8name/var8text';

print '<table>';

while ($i < 9) {

$temp = "$sub.$i";

@xr = split("/",$temp);

print '<tr><td>',$xr[0],'</td><td>',$xr[1],'';

$i++;

}

print '</table>';





I want to fix this statement: $temp = "$sub.$i";

I can't get the split to work with a variable name that's interpolated... so I made an assign stantement, just to see if I could interpolate and assign the variable another way... no luck...

can anyone out there make this code work? NOTE : Changing the variables the way they are passed is not an option... It's embedded in a client module, can't change it... So it's going to pass me 8 variables, as noted above...



thanks, and if you don't have specific knowledge to bring to bear on this issue, kindly exit without comment...



thanks...


fixles
Novice

Aug 17, 2011, 10:12 AM

Post #16 of 32 (5049 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

Lol FAIL. You're projecting again, you're so far in the closet you're in Narnia having tea with Mr Tumnus.


rmh_va
Novice

Aug 17, 2011, 10:19 AM

Post #17 of 32 (5047 views)
Re: [fixles] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

please ignore the replies before, some gay guy from the U.K.... he sent me all kinds of personal replies, even after I told him I'm not gay/interested, he wouldn't stop... pretty sick stuff... if any of you get replies from this guy, delete them, they're not worth opening...



I orignially asked if anyone knows how to fix my interpolation problem...



here's the code...



I have 8 variables... I would like to reference them in a loop without hard-coding the names...

$sub1 = 'var1name/var1text';

$sub2 = 'var2name/var2text';

$sub3 = 'var3name/var3text';

$sub4 = 'var4name/var1text';

$sub5 = 'var5name/var1text';

$sub6 = 'var6name/var1text';

$sub7 = 'var7name/var7text';

$sub8 = 'var8name/var8text';

print '<table>';

while ($i < 9) {

$temp = "$sub.$i";

@xr = split("/",$temp);

print '<tr><td>',$xr[0],'</td><td>',$xr[1],'';

$i++;

}

print '</table>';





I want to fix this statement: $temp = "$sub.$i";

I can't get the split to work with a variable name that's interpolated... so I made an assign stantement, just to see if I could interpolate and assign the variable another way... no luck...

can anyone out there make this code work? NOTE : Changing the variables the way they are passed is not an option... It's embedded in a client module, can't change it... So it's going to pass me 8 variables, as noted above...



thanks, and if you don't have specific knowledge to bring to bear on this issue, kindly exit without comment...



thanks...


fixles
Novice

Aug 17, 2011, 10:24 AM

Post #18 of 32 (5044 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

You need to create a hash. Your trying to use what's called a symbolic reference which is a very bad idea.


FishMonger
Veteran / Moderator

Aug 17, 2011, 10:32 AM

Post #19 of 32 (5043 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

At the point where the vars are being passed to you, assign them to an array or a hash and then loop over that instead of using symbolic references.


rmh_va
Novice

Aug 17, 2011, 10:43 AM

Post #20 of 32 (5039 views)
Re: [FishMonger] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

for at least the 10th time, I do not have access to the code that creates these variables, it's done elsewhere, and I don't have auth. to change it... Of course an array would be smarter/better, but it's not available... stop suggesting this, if you don't know how to do the interpolaiton, kindly leave this to someone that does...



I orignially asked if anyone knows how to fix my interpolation problem...



here's the code...



I have 8 variables... I would like to reference them in a loop without hard-coding the names...

$sub1 = 'var1name/var1text';

$sub2 = 'var2name/var2text';

$sub3 = 'var3name/var3text';

$sub4 = 'var4name/var1text';

$sub5 = 'var5name/var1text';

$sub6 = 'var6name/var1text';

$sub7 = 'var7name/var7text';

$sub8 = 'var8name/var8text';

print '<table>';

while ($i < 9) {

$temp = "$sub.$i";

@xr = split("/",$temp);

print '<tr><td>',$xr[0],'</td><td>',$xr[1],'';

$i++;

}

print '</table>';





I want to fix this statement: $temp = "$sub.$i";

I can't get the split to work with a variable name that's interpolated... so I made an assign stantement, just to see if I could interpolate and assign the variable another way... no luck...

can anyone out there make this code work? NOTE : Changing the variables the way they are passed is not an option... It's embedded in a client module, can't change it... So it's going to pass me 8 variables, as noted above...



thanks, and if you don't have specific knowledge to bring to bear on this issue, kindly exit without comment...



thanks...


fixles
Novice

Aug 17, 2011, 11:17 AM

Post #21 of 32 (5037 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

I think every beginning perl programmer has the idea of dynamically assigning variables after all you can do it in PHP with $$varname but fishmonger is right AT THE POINT YOU CAN CHANGE IT OR IN YOUR OWN PROGRAM CREATE A HASH OR ARRAY AND PASS THESE VARIABLES INTO IT.

God your dumb.

Your not gonna get another answer than that because its not the way your problem is solved in perl.

PS: Your style of writing is... childish


rmh_va
Novice

Aug 17, 2011, 11:20 AM

Post #22 of 32 (5035 views)
Re: [fixles] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

I orignially asked if anyone knows how to fix my interpolation problem...



here's the code...



I have 8 variables... I would like to reference them in a loop without hard-coding the names...

$sub1 = 'var1name/var1text';

$sub2 = 'var2name/var2text';

$sub3 = 'var3name/var3text';

$sub4 = 'var4name/var1text';

$sub5 = 'var5name/var1text';

$sub6 = 'var6name/var1text';

$sub7 = 'var7name/var7text';

$sub8 = 'var8name/var8text';

print '<table>';

while ($i < 9) {

$temp = "$sub.$i";

@xr = split("/",$temp);

print '<tr><td>',$xr[0],'</td><td>',$xr[1],'';

$i++;

}

print '</table>';





I want to fix this statement: $temp = "$sub.$i";

I can't get the split to work with a variable name that's interpolated... so I made an assign stantement, just to see if I could interpolate and assign the variable another way... no luck...

can anyone out there make this code work? NOTE : Changing the variables the way they are passed is not an option... It's embedded in a client module, can't change it... So it's going to pass me 8 variables, as noted above...



thanks, and if you don't have specific knowledge to bring to bear on this issue, kindly exit without comment...


fixles
Novice

Aug 17, 2011, 11:30 AM

Post #23 of 32 (5034 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

I cant speak on behalf of everyone but I'm guessing most people when opening a forum post will read from top to bottom so as to see what has already been said and suggested. So positing your original question endless times at the bottom is well... quite like yourself utterly stupid (See what I did there... punctuation FAIL)

I do however have some serious advice for you. I don't know how old you are but getting along with people is the most important skill you can have in this life so I'm afraid your problem has only one solution go visit mum, dad and grandma in the next life by the most expedient means available to you.


rmh_va
Novice

Aug 17, 2011, 11:31 AM

Post #24 of 32 (5032 views)
Re: [fixles] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post

I orignially asked if anyone knows how to fix my interpolation problem...



here's the code...



I have 8 variables... I would like to reference them in a loop without hard-coding the names...

$sub1 = 'var1name/var1text';

$sub2 = 'var2name/var2text';

$sub3 = 'var3name/var3text';

$sub4 = 'var4name/var1text';

$sub5 = 'var5name/var1text';

$sub6 = 'var6name/var1text';

$sub7 = 'var7name/var7text';

$sub8 = 'var8name/var8text';

print '<table>';

while ($i < 9) {

$temp = "$sub.$i";

@xr = split("/",$temp);

print '<tr><td>',$xr[0],'</td><td>',$xr[1],'';

$i++;

}

print '</table>';





I want to fix this statement: $temp = "$sub.$i";

I can't get the split to work with a variable name that's interpolated... so I made an assign stantement, just to see if I could interpolate and assign the variable another way... no luck...

can anyone out there make this code work? NOTE : Changing the variables the way they are passed is not an option... It's embedded in a client module, can't change it... So it's going to pass me 8 variables, as noted above...



thanks, and if you don't have specific knowledge to bring to bear on this issue, kindly exit without comment...


fixles
Novice

Aug 17, 2011, 11:34 AM

Post #25 of 32 (5031 views)
Re: [rmh_va] anyone OTHER THAN FISHMONGER know how to interpolate variable names in a loop? [In reply to] Can't Post


In Reply To
thanks, and if you don't have specific knowledge to bring to bear on this issue, kindly exit without comment...


I don't have specific knowledge to bring to bear on this issue so I will kindly exit without comment.

First page Previous page 1 2 Next page Last page  View All
 
 


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

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