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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic/concatenate variable 1

Status
Not open for further replies.

egrant

Programmer
Mar 6, 2003
42
0
0
AU
Hi All,

I have been researching on this forever and can't find an answer.

I need to rename my variable depending on what my counter value is for each total in my query array. For instance I would like a unique Total for each record so I can refer to all the records once I am out of the array. Something like;

while (@RowDetails = $RowDetails_sth->fetchrow_array())
{
Counter ++
$Total_$Counter = $RowDetails[0]
}
...

print $Total_1
print $Total_2
print $Total_3
etc...

This is not working for me and I totally lost on how to do it. Any help or pointing in the right direction would be much appreciated!

Thanks,

E
 
woops that should be

$Counter ++

in my array...
 
Why not put this into an array instead?

Code:
my @totals;
my $counter = 0;

while (@RowDetails = $RowDetails_sth->fetchrow_array())
{
   $total[$counter] = $RowDetails[0];
   $counter++;
}
...

foreach $total (@totals)
{
    print "$total";
}

- Rieekan
 
That really helps :)

Thanks for your reply!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top