L
lance-news
Hey all,
Another question based on responses I received to another post
headed "concatenate variables during looping question". It was
recommended that I use a better data structure and that array(S)
would be a better choice for my structure then individual variables.
My basic question is how can I create arrays from the code below to
to create a better and simpler data structure?
Basically I open a Word Doc full of tables and have setup some regexp's
to grab numbers from these tables and then import them into excel.
These regexp'S are the same except for the middle string (i.e CLOTHEING, ITEMS ...)
and the variable names at the end.
My initial guess would be to create an array with the regexp search string
OVERALL RATING, CLOTHING ... and another array containing the results @JA13.
I have no idea how to set this up though?
###### JA ######
$file=~/(TABLE\s+36.*?TABLE 37)/s;
my $fileja=$1;
$fileja =~/TABLE\s+36.*?JA.*?OVERALL RATING.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_1 = $1;
$fileja =~/TABLE\s+36.*?JA.*?CLOTHING.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_2 = $1;
$fileja =~/TABLE\s+36.*?JA.*?ITEMS.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_3 = $1;
$fileja =~/TABLE\s+36.*?JA.*?ACCESSORIES.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_4 = $1;
$fileja =~/TABLE\s+36.*?JA.*?SHOES.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_5 = $1;
$fileja =~/TABLE\s+36.*?JA.*?FINE JEWELRY.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s; my $JA13_6 = $1;
###### KS ######
$file=~/(TABLE\s+37.*?TABLE 38)/s;
my $fileks=$1;
$fileks =~/TABLE\s+37.*?KS.*?OVERALL RATING.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_1 = $1;
$fileks =~/TABLE\s+37.*?KS.*?CLOTHING.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_2 = $1;
$fileks =~/TABLE\s+37.*?KS.*?ITEMS.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_3 = $1;
$fileks =~/TABLE\s+37.*?KS.*?ACCESSORIES.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_4 = $1;
$fileks =~/TABLE\s+37.*?KS.*?SHOES.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_5 = $1;
$fileks =~/TABLE\s+37.*?KS.*?FINE JEWELRY.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s; my $KS13_6 = $1;
# Answers from previous post
# Assign some values to each array
$Sheet->Cells(16, $i)->{Value} = $Ja13[$_ - 1] for 2 .. 7;
$Sheet->Cells(34, $i)->{Value} = $Ks13[$_ - 1] for 2 .. 7;
Again,
Thanks in advance
Lance
Another question based on responses I received to another post
headed "concatenate variables during looping question". It was
recommended that I use a better data structure and that array(S)
would be a better choice for my structure then individual variables.
My basic question is how can I create arrays from the code below to
to create a better and simpler data structure?
Basically I open a Word Doc full of tables and have setup some regexp's
to grab numbers from these tables and then import them into excel.
These regexp'S are the same except for the middle string (i.e CLOTHEING, ITEMS ...)
and the variable names at the end.
My initial guess would be to create an array with the regexp search string
OVERALL RATING, CLOTHING ... and another array containing the results @JA13.
I have no idea how to set this up though?
###### JA ######
$file=~/(TABLE\s+36.*?TABLE 37)/s;
my $fileja=$1;
$fileja =~/TABLE\s+36.*?JA.*?OVERALL RATING.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_1 = $1;
$fileja =~/TABLE\s+36.*?JA.*?CLOTHING.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_2 = $1;
$fileja =~/TABLE\s+36.*?JA.*?ITEMS.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_3 = $1;
$fileja =~/TABLE\s+36.*?JA.*?ACCESSORIES.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_4 = $1;
$fileja =~/TABLE\s+36.*?JA.*?SHOES.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $JA13_5 = $1;
$fileja =~/TABLE\s+36.*?JA.*?FINE JEWELRY.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s; my $JA13_6 = $1;
###### KS ######
$file=~/(TABLE\s+37.*?TABLE 38)/s;
my $fileks=$1;
$fileks =~/TABLE\s+37.*?KS.*?OVERALL RATING.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_1 = $1;
$fileks =~/TABLE\s+37.*?KS.*?CLOTHING.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_2 = $1;
$fileks =~/TABLE\s+37.*?KS.*?ITEMS.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_3 = $1;
$fileks =~/TABLE\s+37.*?KS.*?ACCESSORIES.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_4 = $1;
$fileks =~/TABLE\s+37.*?KS.*?SHOES.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s;my $KS13_5 = $1;
$fileks =~/TABLE\s+37.*?KS.*?FINE JEWELRY.*?MEAN.*?(?\d{1,3}\.\d\d)\s+){1}/s; my $KS13_6 = $1;
# Answers from previous post
# Assign some values to each array
$Sheet->Cells(16, $i)->{Value} = $Ja13[$_ - 1] for 2 .. 7;
$Sheet->Cells(34, $i)->{Value} = $Ks13[$_ - 1] for 2 .. 7;
Again,
Thanks in advance
Lance