I wrote some code to identify and print HTML tables below:

use strict;

my @table;
my $logfile;
my $counter;
my $inc;
my @array;

die "You must enter an argument. \n" if $#ARGV <0;
$logfile = chomp ($ARGV);
foreach my $line(<>)    {
        
        if ($line =~ /(TABLE)(.+)/) {
        $inc++;

        }
        
        $table[$inc] .= $line; # append each line to the array element
                
        $counter++;
        
}

# Print out each table to show that the script works.   

foreach my $lineno (0..$#table) {
        print "TABLE: $lineno \n";
        print $table[$lineno];
        print "\n\n\n";
        sleep 1;
}



The problem I am stuck with is that now I want to sort the tables based
on a Priority (which range from 1-3). There may be several tables with
the same priority numbers.   An example of a Priority 3 would be:

<td valign=top style='width:23%;padding:3.75pt; '><p
class=MsoNormal><span
style='font-size:10.0pt;font-family:Verdana;mso-bidi-font-family:Arial'>
Priority</span><span
style='font-size:10.0pt;font-family:Verdana'><o:p></o:p></span></p></td>
<td valign=top style='width:76%;padding:3.75pt; '><p
class=MsoNormal><span
style='font-size:10.0pt;font-family:Verdana;mso-bidi-font-family:Arial'>
3</span><span
style='font-size:10.0pt;font-family:Verdana'><o:p></o:p></span></p></td>

I need help in understanding the methodology in how to extract these 2
items and then sort the tables in Priority order (all the 1's, 2's and
3's). 

Thanks.

--Paul

Reply via email to