This question piggy backs on my "getting a hash key based on value" thread.
Now that I have my proper month numbers and text in arrays (Thanks PaulTEG
), I want to somehow concatinate the array slices to a variable name so I can increment it (count instances of it) later in my program. So here is my swipe at it. For all I know it may work, but if you guys have any thoughts........
then I am going to try to use it later as in:
or maybe
Am I smoking something here thinking it will work?
Now that I have my proper month numbers and text in arrays (Thanks PaulTEG
![[medal] [medal] [medal]](/data/assets/smilies/medal.gif)
Code:
#
# Get the months for the 4 month chart
#
$curr=$rpt_month;
my @text =("January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December");
my @months =('01','02','03','04',
'05','06','07','08',
'09','10','11','12');
my @last4months=($months[$curr-4],$months[$curr-3],$months[$curr-2],$months[$curr-1]);
my @last4text =($text[$curr-4],$text[$curr-3],$text[$curr-2],$text[$curr-1]);
print (LOG "Months for 4 month chart: @last4text\n\n");
my ("$close_cnt_" . "$last4months[0]") = 0;
my ("$close_cnt_" . "$last4months[1]") = 0;
my ("$close_cnt_" . "$last4months[2]") = 0;
my ("$close_cnt_" . "$last4months[3]") = 0;
my ("$open_cnt_" . "$last4months[0]") = 0;
my ("$open_cnt_" . "$last4months[1]") = 0;
my ("$open_cnt_" . "$last4months[2]") = 0;
my ("$open_cnt_" . "$last4months[3]") = 0;
then I am going to try to use it later as in:
Code:
("$close_cnt_" . "$last4months[0]")++
or maybe
Code:
("$close_cnt_$last4months[0]")++
Am I smoking something here thinking it will work?