[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 712
  • Last Modified:

Perl arrays or hash? or hashes of arrays? or array of hashes?

I have a stream of data being passed to me which I then unpack into arrays.  For each item of the first array I must find the matching item(s) in the other arrays and print them out in a table.  Pseudo-code Example:

Array1=(A-Group A,B-2002 Fabrication,C-2003 Fabrication)
Array2=(A001-PRI-RED-DESCRIPTION, A001-PRI-BLU-DESCRIPTION, A001-PRI-BLK-DESCRIPTION,
               A001-PRI-GRN-DESCRIPTION, A001-PRI-YLW-DESCRIPTION, A001-PRI-MLT-DESCRIPTION,
               A002-PRI-RED-DESCRIPTION, A002-PRI-BLK-DESCRIPTION, A002-PRI-BLU-DESCRIPTION,  
               B001-PRI-RED-DESCRIPTION, B001-PRI-BLK-DESCRIPTION, B001-MIN-BLK-DESCRIPTION,
               B001-MIN-MLT-DESCRIPTION,
               C010-COL1-RED-DESCRIPTION, C010-COL1-YLW-DESCRIPTION,
               C010-PRI-TRQ-DESCRIPTION, C010-MIN-BLK-DESCRIPTION, C010-MIN-MLT-DESCRIPTION)
Array3=(A001-CODE1:3.0000-CODE2:0.0000-CODE3:3.0000-CODE4:12.2500-CODE5:4.4400,
               A002-CODE1:3.0000-CODE2:0.0000-CODE3:3.0000-CODE4:12.2500,
               B001-CODE1:3.0000-CODE2:0.0000,
               C010-CODE2:3.0000-CODE3:0.0000-CODE4:1.0000-CODE5:0.5000-CODE6:0.2500-CODE8:4.0600-CODE12:3.3600)
Array4=(A001-Vision-Vision2-Vision3, A002-Vision-Vision2-999,
              B001-Vision-Vision2-vision3-Vision4,
              C010-Vision3-Vision4-Vision8)
Array5=(A001-2002 Collection-102-1.00-Large-Soon--20020310-20020414,A002-2002 Collection-001-1.00-Large-Soon-See Thomas-20010310-20010414,B001-Cha Cha-002-1.00-Medium-Immediately--20010310-20010414,C010-Blah-44-2.00-Small-Immediately--20010310-20020414)
foreach item(Array1)
            find matching item(s) in array2, get fields,
                  if COL1 found  print COLOR:DESCRIPTION in cell 1
                  if COL2 found print  COLOR:DESCRIPTION in cell 2
            find matching lines in array3, print code selections to drop down listbox in cell 3
            find matching lines in array4, print SIZE in cell 4, QTY in cell 5

Of course, there could be hundreds of items in array1.  Probably no more than 50 items in any of the other 3 arrays.

The items in arrays2,3 & 4 will always be in A,B,C,D order.  If I'm searching for A, I could stop when I find no more A's and hold my place if I knew how...nested if statements?

What's the best way to get the fields out of each line when they're delimited by a hyphen?  Should I create hashes of some sort?   Can I unpack into hashes?  I couldn't find much info on packing/unpacking....

What's the best way to handle the processing of so much data?  Is it even possible?   This is only a small part of the program, but it's got me stumped.  

Here's a bit of the actual code I use to unpack data:

sub GetTable1{
   my($bits,$message) =@_;
   while ($table eq "01"){
      $alpha                          = unpack "x$bits A1", $message;$bits+=1;
      $alpha_description   = unpack "x$bits A70",  $message;$bits+=70;
      $table                          = unpack "x$bits A2", $message;$bits+=2;
      push(@Array1,$alpha);
  }    
 return($bits);
}        

sub GetTable2{
   my($bits,$message) =@_;
   while ($table eq "02"){
       $alpha                        = unpack "x$bits A1", $message;$bits+=1;
       $column_indicator   = unpack "x$bits A4",  $message;$bits+=4;
       $color_code              = unpack "x$bits A3", $message;$bits+=3;
       $color_description   = unpack "x$bits A70",  $message;$bits+=70;
       $table                          = unpack "x$bits A2", $message;$bits+=2;
       push(@Array2,"$alpha-$column_indicator-$color_code-$color_description");
  }    
  return($bits);
}        

Help, this is way over my head! And I have 28 tables to parse!




0
isarana
Asked:
isarana
  • 18
  • 14
  • +1
1 Solution
 
ozoCommented:
How do you print  COLOR:DESCRIPTION in cell 1 ?
0
 
maneshrCommented:
isarana,

What exactly do you mean by a cell? Are you referring to columns in a HTML table?

Given the above array, can you pl post how you want the output to look like?

Please explain in detail the exact output that you want.

This will help you get a more accurate answer., faster.
0
 
TsvetomirCommented:
Yes , with references you can hadle all types of datasructures: matrices, trees and s.o.

I was going to write you the all the code but now I' ll post just part of it  to be sure that that's what you want.

(the third part -  ..."find matching lines in array3, print code selections to drop down listbox in cell 3 " ?It's easy to fill that to I didi't wrote it just becouse you have post sub GetTable3)


.....

## the data structure (reference  to hash of arrays):
$ref3 = {A=>["CODE1", "CODE2", "CODE3", "CODE4", "CODE5"],
              B=>["CODE1", "CODE2"],
              C=>["CODE1", "CODE3", "CODE4", "CODE5"],
              D=>["CODE2", "CODE3", "CODE5", "CODE6", "CODE7", "CODE8"] };




## the code to print that part of the table
#(jump box in a the third column with the code for the proper item):

print "<TD>";
print '<SELECT name="code">';
foreach $code ( @{$ref3->{$item}} ) {
     print "<OPTION>$code</OPTION>";
}    
print "</SELECT>";
print "<TD>";


.......


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
isaranaAuthor Commented:
Tsvetomir, Not sure what your code prints out, I actually need 4 different drop down lists, maybe I can  do something like:

foreach $code ( @{$ref3->{$item}} )
{   if($code eq @Array1[$count]{
    print "<OPTION>$code</OPTION>" ;}
}

And actually it's a bit more complicated since the keys in the other arrays could be A1, A2, A3 and all must print in separate sections under title A...

maneshr,

Cell refers HTML table...it has to print out something like this:
________________________________________________
TITLE:  A
_______________________________________________
A-1
-------------------------------------------------
1ST  BOX          2ND BOX           SELECT BOX    
                         
RED DESC                            CODE1
BLU DESC                            CODE2  
BLK DESC                            CODE3
GRN DESC                            CODE4
YLW DESC                            CODE5
MLT DESC
------------------------------------------------
SIZE1: 245        SIZE2: 1597         SIZE3: 987
________________________________________________
A-2
------------------------------------------------
1ST  BOX          2ND BOX           SELECT BOX    
                         
RED DESC                            CODE1
BLU DESC                            CODE2  
BLK DESC                            CODE3
                                    CODE4
               
------------------------------------------------
SIZE1: 245        SIZE2: 1597         SIZE3: 987



_______________________________________________________
TITLE:  B
_______________________________________________________
B-1
-------------------------------------------------------
1ST  BOX          2ND BOX           SELECT BOX    
                         
RED DESC          BLK DESC          CODE1
BLK DESC          MLT DESC          CODE2
----------------------------------------------------
SIZE1: 467        SIZE2: 849
 
I'll mock up an HTML page so you can see how it's supposed to look...it would be much easier if I just received all the data for A, then all the data for B, then C etc.
0
 
maneshrCommented:
isarana,

Where does A-1, A-2, B-1 etc. come from?

i cannot see them in the "array" that you posted at the top. So where do they come from?

0
 
isaranaAuthor Commented:
maneshr-
I have edited the original question to clarify...I was trying to simplify my question, but I guess I just made it more confusing...

If Array1 has (A,B,C,D)
Then Array2,Array3 and Array4 can have any number of A's, B's, C's, and D's...could have A1 through A100, B1 through B25, C1 through C50, etc.  A is the main category, 1-100 would be subcategories.

0
 
isaranaAuthor Commented:
mock up of how it should look is at
http://www.dr9.com/furlessleader/
(in this mockup, the edit buttons would open a pop-up to edit the data but non functional now)
As in above edited question, I'm pushing from a stream of data into arrays...don't know if I should be pushing into hashes, or making hashes of hashes, or just keep in arrays and go through Arrays2-5 looking for match for each item in Array1 and print.  Since there's potentially hundreds of categories and subcategories, I'm not sure what most efficient is...

0
 
maneshrCommented:
isarana,

".. A is the main category, 1-100 would be subcategories..."

Aha!!Now that makes more sense. That plus the update to the data in the original question is very helpful.

".mock up of how it should look is at http://www.dr9.com/furlessleader/.."
Again, this is very useful too.

Given this wealth of new & useful info, i am in a better position to provide you with a working solution.

I will keep you posted on the progress of the script.

0
 
maneshrCommented:
isarana,

".. http://www.dr9.com/furlessleader/.."

Quick question.

The output of the script will be in a basic HTML table, based on the above URL.

However, you will have to add the colors, captions, images and other elements.

Let me know if this is ok with you.

0
 
maneshrCommented:
isarana,

Another question.

i can see inconsistency in your data for Array5

Array5=(A001-2002 Collection-102-1.00-Large-Soon-20020310-20020414,A002-2002 Collection-001-1.00-Large-Soon-See
Thomas-20010310-20010414,B001-Cha Cha-002-1.00-Medium-Immediately-20010310-20010414,C010-Blah-44-2.00-Small-Immediately-20010310-20020414)

A002 has NOTES (See Thomas) column in it, but none of the others have that column.

Can you please explain that?
0
 
isaranaAuthor Commented:
"...Let me know if this is ok with you."
 I appreciate any help at all!  

"...A002 has NOTES (See Thomas) column in it, but none of the others have that column."
I again have edited original question so there is a blank field in Array5 for Notes column.  I am building a string delimited by hyphens '-', in some cases the field will be blank...my mistake in illustrating Array5.

right now I have something like the following:
foreach $line(@Array1){
   ($category,$description)=split(/-/,$line);
   foreach $line(@Array2){
        if($line =~ /$category/ ){
            ($categorykey,$pri_min_ind,$color_code,$description)=split(/\,/,$line);
            print "html table with variables here";
        }
   }
    print "<select>";
    foreach $line(@Array3){
         if($line =~ /$category/ ){
             ($categorykey,$code,$quantity)=split(/-/,$line);
              print "<option>$code $quantity</option>";
         }
    }
}
 
and so forth.  (In reality, $catagory is not just letter A, it's a unique 6 digit code but I'm trying to simplify it here)

The problem with this code is I end up going through all the lines of each array, but since the array is sorted I can stop as soon as I find one that's different.  For example, if I'm searching for matches to 'B', I can leave after I get to 'C'.  I tried doing a 'last' if there was no match, but same example is if I'm looking for 'B', I come into the array on 'A'.  I'd like to be able to come into the array on the first occurance of 'B' and leave after the last occurance of 'B' since there's so many items.

Any thoughts appreciated, thanks!
0
 
maneshrCommented:
isarana,

"..I appreciate any help at all!  ..."

Excellent!! i already have a basic code that shows the output in a format very close to HTML.

Would you like to see that first, before i proceed to putting that output in a HTML table?
If yes, then i will expect feedback from you on the output.

Let me know.

".....my mistake in illustrating  Array5....."

So is this the correct representation for Array5?

Array5=(A001-2002 Collection-102-1.00-Large--Soon-20020310-20020414,A002-2002 Collection-001-1.00-Large-Soon-See  Thomas-20010310-20010414,B001-Cha                     Cha-002-1.00-Medium--Immediately--20010310-20010414,C010-Blah-44-2.00-Small--Immediately--20010310-20020414)

NOTE: the 2 -'s after the size column for A001, B001 & A002

0
 
isaranaAuthor Commented:
"...Would you like to see that first, before i proceed to putting that output in a HTML table?"

Whatever is easiest for you, I can wait unless you'd prefer earlier feedback.


"...So is this the correct representation for Array5?"
"...NOTE: the 2 -'s after the size column for A001, B001 & A002"

Actually, only the 2 -'s after the effective column on A001,B001,C002.

Parsing Array5 would be:
($categorykey,$categorytitle,$mod_number,$quantity,$size,$effective,$notes,$from_year,$to_year)=split(/-/,$line);

so $notes would be blank for A001, prints "See Thomas" for A002, blank for B001 and C010.

I build the array by unpacking:

sub GetTable5{
       my($bits,$message) =@_;
        while ($table eq "05"){
                 $categorykey     = unpack "x$bits A6", $message;$bits+=6;
                 $categorytitle     = unpack "x$bits A30",  $message;$bits+=30;
                 $mod_number  = unpack "x$bits A3", $message;$bits+=3;
                 $quantity             = unpack "x$bits A4", $message;$bits+=4;
                 $size                    = unpack "x$bits A10", $message;$bits+=10;
                 $effective             = unpack "x$bits A10", $message;$bits+=10;
                 $from_year         = unpack "x$bits A8", $message;$bits+=8;
                 $to_year              = unpack "x$bits A8", $message;$bits+=8;
                 $notes                 = unpack "x$bits A70",  $message;$bits+=70;
                 $table                   = unpack "x$bits A2", $message;$bits+=2;
                          push(@Array5,"$categorykey-$categorytitle-$mod_number-$quantity-$size-$effective-$notes-$from_year-$to_year");
        }    
        return($bits);
}        

(Note: although the dates are shown on the screen as 10-March-2002, when I unpack them $from_year is 20020310 and $to_year is20020414, I run them through a date conversion to display. )
0
 
maneshrCommented:
isarana,

".. I can wait unless you'd prefer earlier feedback...."

i would prefer feedback as early, & as often, as possible to prevent a whole lot of rework late in the game.

"..Parsing Array5 would be:.."

if you dont mind, please do not post any code.

Help me with the data and i will take care of the code.
Thanks :-)

I should have a basic stripped down version of the code here soon.

0
 
maneshrCommented:
0
 
maneshrCommented:
0
 
maneshrCommented:
isarana,

Based on the data & the discussion we have had so far, i have written this basic, yet fully functional script for you.

This script does the main task, i.e. read the Arrays and relate the data together. Also it presents the data in a way that can be rendered in HTML format.

Here is what i want you to do.

* Verify if the data in the Array is accurate and exactly like you want it.
* Verify that the script works fine on your server.
* Verify that output of the script is close to the HTML page that you want.

NOTE: Please provide your feedback purely from the functional perspective.
Since EE was giving me errors, i have posted the code in 2 parts

Here is Part 1

=========isarana.pl
#!/usr/local/bin/perl

@fmonths = ('Dummy','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

@Array1=('A-Group A','B-2002 Fabrication','C-2003 Fabrication');

@Array2=(
'A001-PRI-RED-DESCRIPTION','A001-PRI-BLU-DESCRIPTION','A001-PRI-BLK-DESCRIPTION',
'A001-PRI-GRN-DESCRIPTION','A001-PRI-YLW-DESCRIPTION','A001-PRI-MLT-DESCRIPTION',
'A002-PRI-RED-DESCRIPTION','A002-PRI-BLK-DESCRIPTION','A002-PRI-BLU-DESCRIPTION',
'B001-PRI-RED-DESCRIPTION','B001-PRI-BLK-DESCRIPTION','B001-MIN-BLK-DESCRIPTION',
'B001-MIN-MLT-DESCRIPTION','C010-COL1-RED-DESCRIPTION','C010-COL1-YLW-DESCRIPTION',
'C010-PRI-TRQ-DESCRIPTION','C010-MIN-BLK-DESCRIPTION','C010-MIN-MLT-DESCRIPTION'
);

@Array3=(
'A001-CODE1:3.0000-CODE2:0.0000-CODE3:3.0000-CODE4:12.2500-CODE5:4.4400',
'A002-CODE1:3.0000-CODE2:0.0000-CODE3:3.0000-CODE4:12.2500',
'B001-CODE1:3.0000-CODE2:0.0000',
'C010-CODE2:3.0000-CODE3:0.0000-CODE4:1.0000-CODE5:0.5000-CODE6:0.2500-CODE8:4.0600-CODE12:3.3600'
);

@Array4=(
'A001-Vision-Vision2-Vision3',
'A002-Vision-Vision2-999',
'B001-Vision-Vision2-vision3-Vision4',
'C010-Vision3-Vision4-Vision8'
);

@Array5=(
'A001-2002 Collection-102-1.00-Large-Soon--20020310-20020414',
'A002-2002 Collection-001-1.00-Large-Soon-See Thomas-20010310-20010414',
'B001-Cha Cha-002-1.00-Medium-Immediately--20010310-20010414',
'C010-Blah-44-2.00-Small-Immediately--20010310-20020414'
);


### Code continued in next post
0
 
maneshrCommented:
### Part 2 of the Code. Continued from previous comment.


foreach $Array1 (@Array1){
     ($main,$main_name)=split(/-/,$Array1);

     foreach $Array2 (@Array2){
          if ($Array2=~ /^($main\d+)\-(.*)/){
               push(@$1,$2);
               $sub_hash{$1}++;
          }
     }
}

foreach $Array1 (@Array1){
     ($main,$main_name)=split(/-/,$Array1);
     print "<B>Category: $main TITLE: $main_name</B>\n";

     foreach $Array2 (sort keys %sub_hash){
          if ($Array2=~ /^($main)(\d+)/){
               print "\tCategory/Seq: $1/$2";

               foreach $Array5 (@Array5){
                    if ($Array5=~ /^$Array2\-/){
                         @a5_info=split(/-/,$Array5);
                         print "\tName: $a5_info[1] MOD:$a5_info[2]\n";
                    }
               }

               print "\t\t\tPrimary\n";
               print "\t\t",join("\n\t\t",@$Array2),"\n";

               foreach $Array3 (@Array3){
                    if ($Array3=~ /^$Array2\-(.*)/){
                         $option=$1;
                         $option=~ s/:/ /g;
                         @option=split(/-/,$option);

                         print "\t\t\tCode Quantity:\n";
                         print "\t\t",join("\n\t\t",@option),"\n";
                    }
               }

               foreach $Array4 (@Array4){
                    if ($Array4=~ /^$Array2\-(.*)/){
                         undef (@alpha);
                         undef (@numeric);
                         $option=$1;
                         @option=split(/-/,$option);

                         foreach (@option){
                              if (/^\d+$/){
                                   push(@numeric,$_);
                              }else{
                                   push(@alpha,$_);
                              }
                         }
                         print "\t\t\tAdd Fields\n";
                         print "\t\tAlpha:\t",join("\t",@alpha),"\n";
                         print "\t\tNumeric:\t",join("\t",@numeric),"\n";
                    }
               }

               foreach $Array5 (@Array5){
                    if ($Array5=~ /^$Array2\-/){
                         @info=split(/-/,$Array5);

                         ##     Convert date from YYYYMMDD to DD-MON-YYYY format.
                         $info[7]=~ s/(\d{4})(\d{2})(\d{2})/$3-$fmonths[$2]-$1/;
                         $info[8]=~ s/(\d{4})(\d{2})(\d{2})/$3-$fmonths[$2]-$1/;

                         print qq{\t\tQuantity: $info[3]\t\tSize: $info[4]
\t\tEffective: $info[5]
\t\tNotes: $info[6]
\t\tAvailable Dates: $info[7] \t to:\t $info[8]\n};
                    }
               }
          }     ##     End of Hash' if
     }
}
0
 
isaranaAuthor Commented:
maneshr,

"...* Verify if the data in the Array is accurate and exactly like you want it."
PERFECT!

"... * Verify that output of the script is close to the HTML page that you want."
  I added my HTML code for table formatting, VERY NICE!

"... * Verify that the script works fine on your server."
1) I had  trouble with the 2nd foreach loop
                         foreach $Array2 (@Array2){
                              if ($Array2=~ /^($main\d+)\-(.*)/){
                                   push(@$1,$2);                      
                                   $sub_hash{$1}++;
                              }
                         }
 where it didn't like "push(@$1,$2)" so I changed to" push(@1,$2)" and it compiled.
Can you explain what this part of the code does?  

2) print "\t\t\tPrimary\n";
    print "\t\t",join("\n\t\t",@$Array2),"\n";
   
   gives me no values, if I change it to
       print "\t\t",join("\n\t\t",@Array2),"\n";

   it prints out the entire line.  Is it because I made the change above?

Thanks for all your effort!
         

 
0
 
maneshrCommented:
isarana,

"..PERFECT!..."

Excellent!!

".. VERY NICE! ..."

Great news!!!

".. I had  trouble with the 2nd foreach loop.."

What exactly do you mean by trouble? Do you mean you got an error in Perl OR you could not understand that line of code?

The entire for loop MUST remain as-is & should not be modified.

I will be happy to explain what it means, as long as you keep it the way it is.

Let me know.

".. it prints out the entire line.  Is it because I made the change above?..."

I am sure it is due to the change you made, cause even now the script works just fine with the original code in it.
0
 
isaranaAuthor Commented:
maneshr,

"...What exactly do you mean by trouble? Do you mean you got an error in Perl OR you could not understand that line of code?"

I get the following compile error in Perl:

Number found where operator expected at testcost.cgi line 51, near "@$1"
        (Missing operator before 1?)
syntax error at testarrays.cgi line 51, near "@$1"
Execution of testarrays.cgi aborted due to compilation errors.        
0
 
maneshrCommented:
isarana,

"..Number found where operator expected at testcost.cgi line 51, near "@$1".."

Are you using the -w switch? Are you using the strict module?

Can you pl. post the >exact< code that you are using here?

Let me know.
0
 
isaranaAuthor Commented:
maneshr,

Server has this version of perl:

This is perl, version 5.003 with EMBED  
0
 
maneshrCommented:
isarana,

"..This is perl, version 5.003 with EMBED  ..."

i am using perl, version 5.005_02 built for sun4-solaris on my server.

Meanwhile, in addition to the above questions, let me know what OS you are on.
0
 
isaranaAuthor Commented:
maneshr,
Here's exact code:

#!/usr/local/bin/perl

unshift(@INC, '.');

use CGI;

MAIN: {
  $query = new CGI;

  print $query->header;
  print $query->start_html;


  @fmonths =('Dummy','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  @Array1=('A-Group A','B-2002 Fabrication','C-2003 Fabrication');
  @Array2=('A001-PRI-RED-DESCRIPTION','A001-PRI-BLU-DESCRIPTION','A001-PRI-BLK-DESCRIPTION','A001-PRI-GRN-DESCRIPTION','A001-PRI-YLW-DESCRIPTION','A001-PRI-MLT-DESCRIPTION','A002-PRI-RED-DESCRIPTION','A002-PRI-BLK-DESCRIPTION','A002-PRI-BLU-DESCRIPTION','B001-PRI-RED-DESCRIPTION','B001-PRI-BLK-DESCRIPTION','B001-MIN-BLK-DESCRIPTION','B001-MIN-MLT-DESCRIPTION','C010-COL1-RED-DESCRIPTION','C010-COL1-YLW-DESCRIPTION','C010-PRI-TRQ-DESCRIPTION','C010-MIN-BLK-DESCRIPTION','C010-MIN-MLT-DESCRIPTION'
 );
 @Array3=('A001-CODE1:3.0000-CODE2:0.0000-CODE3:3.0000-CODE4:12.2500-CODE5:4.4400','A002-CODE1:3.0000-CODE2:0.0000-CODE3:3.0000-CODE4:12.2500','B001-CODE1:3.0000-CODE2:0.0000','C010-CODE2:3.0000-CODE3:0.0000-CODE4:1.0000-CODE5:0.5000-CODE6:0.2500-CODE8:4.0600-CODE12:3.3600'
  );

  @Array4=('A001-Vision-Vision2-Vision3',
           'A002-Vision-Vision2-999',
           'B001-Vision-Vision2-vision3-Vision4',
           'C010-Vision3-Vision4-Vision8'
            );

 @Array5=('A001-2002 Collection-102-1.00-Large-Soon--20020310-20020414',
          'A002-2002 Collection-001-1.00-Large-Soon-See Thomas-20010310-20010414',
          'B001-Cha Cha-002-1.00-Medium-Immediately--20010310-20010414',
          'C010-Blah-44-2.00-Small-Immediately--20010310-20020414'
           );


print "<table border=1 bgcolor=#CCCCFF>";
   foreach $Array1 (@Array1){
         ($main,$main_name)=split(/-/,$Array1);
         foreach $Array2 (@Array2){
               if ($Array2=~ /^($main\d+)\-(.*)/){
                  push(@$1,$2);
                  $sub_hash{$1}++;
               }
          }
  }

  foreach $Array1 (@Array1){
          ($main,$main_name)=split(/-/,$Array1);
          print "<tr><td colspan=3 bgcolor=#000066>
                       <font color=white><B>CATEGORY:
                       $main &nbsp;&nbsp;
                     <B>TITLE: $main_name</B></font></td></tr>";

          foreach $Array2 (sort keys %sub_hash){
                  if ($Array2=~ /^($main)(\d+)/){
                      print "<tr><td colspan=3 bgcolor=#CCCCCC>
                        Category/Seq: $1/$2 &nbsp;&nbsp;";
                      foreach $Array5 (@Array5){
                         if ($Array5=~ /^$Array2\-/){
                            @a5_info=split(/-/,$Array5);
                            print "Name: $a5_info[1]
MOD:$a5_info[2]</td></tr>";
                         }
                  }

                  print "<tr><td>Primary:";
                  print "<br>",join("<br>",@$Array2),"</td>";

                  foreach $Array3 (@Array3){
                       if ($Array3=~ /^$Array2\-(.*)/){
                           $option=$1;
                           $option=~ s/:/ /g;
                           @option=split(/-/,$option);
                           print "<td>Code Quantity:</td><td>";
                           print "&nbsp;",join("<br>",@option),"</td></tr>";
                       }
                  }

                  foreach $Array4 (@Array4){
                         if ($Array4=~ /^$Array2\-(.*)/){
                             undef (@alpha);
                             undef (@numeric);
                             $option=$1;
                             @option=split(/-/,$option);
                             foreach (@option){
                                 if (/^\d+$/){
                                        push(@numeric,$_);
                                 }else{
                                        push(@alpha,$_);
                                }
                         }
                        print "<tr><td>Add Fields</td></tr>";
                        print
"<tr><td>Alpha:",join("<br>",@alpha),"</td></tr>";
                        print
"<tr><td>Numeric:",join("<br>",@numeric),"</td></tr>";
                     }
                  }

                  foreach $Array5 (@Array5){
                      if ($Array5=~ /^$Array2\-/){
                            @info=split(/-/,$Array5);
    ##     Convert date from YYYYMMDD to DD-MON-YYYY format.
                             $info[7]=~ s/(\d{4})(\d{2})(\d{2})/$3-$fmonths[$2]-$1/;
                             $info[8]=~ s/(\d{4})(\d{2})(\d{2})/$3-$fmonths[$2]-$1/;
                             print
qq{<tr><td>Quantity:$info[3]<br>Size: $info[4]
                             <br>Effective: $info[5] <br>Notes:
$info[6]
                             <br>Available Dates: $info[7]  to:
$info[8]</td></tr>};
                      }
                  }
              }     ##     End of Hash' if
          }
   }

 print "</table>";
  print $query->end_html;
}

0
 
isaranaAuthor Commented:
maneshr,
More info:

This is perl, version 5.003 with EMBED
        built under solaris at May  4 1997 13:48:18
        + suidperl security patch

Copyright 1987-1996, Larry Wall    

Running on Unix server
0
 
isaranaAuthor Commented:
maneshr,

Solaris 2.5.1 Unix Server...the server is in England, I'm going to try it on a server here in the States and see if it makes any difference.
0
 
isaranaAuthor Commented:
No, same error.
0
 
maneshrCommented:
isarana,

"..see if it makes any difference...."

What is the Perl version of this US based server?

Let me know.
0
 
isaranaAuthor Commented:
maneshr,
 Both servers are Unix Solaris with

This is perl, version 5.003 with EMBED
                            built under solaris at May  4 1997 13:48:18
                            + suidperl security patch

I'm not sure what the suidperl security patch is, and if that's interfering.
0
 
maneshrCommented:
isarana,

"..Both servers are Unix Solaris with .."

Hmm!!! this confirms my fears about the Perl version being at the root of this problem.

Let me work on a round-a-bout way to address this.
NOTE: This method will not be as flexible as the previous method.

0
 
maneshrCommented:
isarana,

So far i have not been able to find a single, reliable workaround to the problem.

Is it possible for you to upgrade the Perl version on your servers, or host on a server that has the recent version?

Let me know.
0
 
isaranaAuthor Commented:
maneshr,

I did find a server with version 5.005 and lo and behold, it works perfectly!!!  My program is supposed to switch to the server with 5.005 within the month, so I'll have to wait until then....

Thanks for all your help, points coming to you.
0
 
maneshrCommented:
isarana,

"..I did find a server with version 5.005 and lo and behold, it works perfectly!!!  ...."

Excellent!!! That is good news indeed!!

Glad to know you got the solution you were looking for.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 18
  • 14
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now