eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
    if 0;

    use LWP::Simple;

    $mach_usagefile = "/tmp/junk.html";
    $mach_usage = get("http://www.sdsc.edu/~marciano/XML/machineusage.html");

    open( TEMP, ">$mach_usagefile" );
    print TEMP $mach_usage;
    close(TEMP);

    open( TEMP, "<$mach_usagefile" );

    $h1line = <TEMP>;

# debugging variable
    $DEF = 0;

    $mach_c = 0;
    $rows = 0;
    $cols = 0;
    $i_c = 1;

#---------------------------------------------------------------
#---- PULL OUT MACHINE header ACRONYMS
    print "\ncode:\n" if $DEF;
    while( $h1line = <TEMP> ) {
       if ( $h1line =~ m/<table/ ) {
          goto W0;
       }
    }

 W0:while( $h1line = <TEMP> ) {
       if ( $h1line =~ m/<a href/ ) {
          $h1line =~ m/>(.+)</ && ($code = $1); 
          print "\t$code\n" if $DEF;
          $code =~ s/\//-/;
          $CODE[++$mach_c] = $code; 
          $AR{ "$code" } = $mach_c;
          goto W1;
       }
    }

 W1:while( $h1line = <TEMP> ) {
       if ( $h1line =~ m/&nbsp;&nbsp;/ ) {
          $code = "";
          $h1line =~ m/>(.+)</ && ($code = $1); 
          if ( $code ne "") { 
             print "\t$code\n" if $DEF; 
             $code =~ s/\//-/;
             $CODE[++$mach_c] = $code;
             $AR{ "$code" } = $mach_c;
          }
          else { 
             for( $i=0; $i<=$#ARGV; $i++ ) {
                $ind = "";
                $ind = $AR{ "$ARGV[$i]" };
                if ($ind != "") {
                   push @FIN, $ind;
                }
             }
             @SFIN = sort @FIN;

             goto W2 
          };
       }
    }

# !!!   AT THIS POINT $mach_c is set...

#---------------------------------------------------------------
 W2:while( $h1line = <TEMP> ) {
       if ( $h1line =~ m/<table/ ) {
          goto W3;
       }
    }

#---- PROCESS ONE MACHINE TABLE at a time
 W3:
    print "\ntable:\n" if $DEF;
    while( $h1line = <TEMP> )
    {
#---- Check for RED COLOR FONT! 
       $queues_count = 0;
       if( $h1line =~ m/660000/ ) {
          $h1line =~ m/<b>(.+)<\/b>/ && ($type = $1); 
          $type =~ s/\//-/;
          print "\ttype= $type\n" if $DEF;
          $TYPE[ $i_c ] = $type; 

          while( $h1line = <TEMP> ) {
#---- Pull out LOAD info TEXT! 
             if( $h1line =~ m/Load:/ ) {
                $h1line = <TEMP>;
                $load = "";
                $h1line =~ m/ (.+)<\/td>/ && ($load= $1); 
                print "\tload= $load\n\n" if $DEF;
                $LOAD[ $i_c ] = $load; 
		$first = 1;

#---- Process QUEUE INFO TABLE
                while( $h1line = <TEMP> ) {
                   if ( $h1line =~ m/<table/ ) {
                      while( $h1line = <TEMP> ) {
                         if ( !($h1line =~ m/^<\/tr>/) ) {
                            if ( !($h1line =~ m/^<\/table>/) ) {
#---- "summary" section DETECTED
                               if ( $h1line eq "<tr>\n" ) {
                                  $h1line = <TEMP>;
                               }
                               if ( $h1line =~ m/<td/ ) {
                                  $val = "";
                                  $h1line =~ m/>(.+)<\/td>/ && ($val= $1); 
                                  $val =~ s/<.+>(\w+)(<.+>)?/$1/;
                                  if ( $val eq "&nbsp;" ) {
                                     $val = "---";
                                  }
                                  if ( $first == 1 ) { 
#---- START OF NEW ROW in QUEUE TABLE
                                     $first = 0; 
                                     $cols = 0;
                                     $rows++;
                                  } 
                                  $cols++; 
                                  print "\tval= $val\n" if $DEF;
                                  $VALS[ $i_c ][ $rows ][ $cols ] = $val;
                               }
                            }
#---- AT this point WE'RE READY TO PROCESS THE NEXT MACHINE INFO!
                            else {
                               $rSIZE[ $i_c ] = $rows;
                               $cSIZE[ $i_c ] = $cols;
                               $queues_count = $queues_count - 2;
                               print "\tcount= $queues_count\n" if $DEF;
                               $COUNT[ $i_c ] = $queues_count;
                               $rows = 0;
                               $i_c++;
                               goto W3;
                            }
                         }
                         else {
		            $first = 1;
                            $queues_count++;
                            print "\n" if $DEF;
                         }
                      }
                   }
                }

             }
          }
       }
    }

    for ( $m = 1; $m <= $mach_c; $m++ ) {
        for ( $c = $cSIZE[$m]; $c > 1; $c-- ) {
            $cc = $c - 1; 
            $VALS[ $m ][ 1 ][ $c ] =  $VALS[ $m ][ 1 ][ $cc ];
        }
        $VALS[ $m ][ 1 ][ 1 ] = ""; 
    }

#***************************************************************
# PRINT IT ALL OUT
#***************************************************************

    print "<machine_usage>\n";
    print "\n";
if ( $#SFIN >= 0 || ($#SFIN == -1 && $#ARGV >= 0) ) {
    for ( $i = 0; $i <= $#SFIN; $i++ ) {
       $m = $SFIN[ $i ]; 
        printf ("%3s<machine>\n");
        printf ("%6s<code>$CODE[ $m ]</code>\n");
        printf ("%6s<type>$TYPE[ $m ]</type>\n");
        printf ("%6s<load>$LOAD[ $m ]</load>\n");

        printf ("%6s<summary>\n");
        for ( $c = 2; $c < $cSIZE[$m]; $c++ ) {
           printf( "%9s<usage type=\"$VALS[1][1][$c]\"");
	   printf( "%1s\t\tvalue=\"$VALS[$m][$rSIZE[$m]][$c]\"/>\n");
        }
        printf ("%6s</summary>\n");

        printf ("%6s<queues count=\"$COUNT[ $m ]\">\n");

        for ( $r = 2; $r < $rSIZE[$m]; $r++ ) {
           printf ("%9s<queue name=\"$VALS[ 1 ][ $r ][ 1 ]\">\n");
           for ( $c = 2; $c <= $cSIZE[$m]; $c++ ) {
              printf ("%12s<usage type=\"$VALS[1][1][$c]\"");
	      printf ("%1s\t value=\"$VALS[$m][$r][$c]\"/>\n");
           }
           printf ("%9s</queue>\n");
        }

        printf ("%6s<queues>\n");
        printf ("%3s</machine>\n\n");
    }
}
else {
    for ( $m = 1; $m <= $mach_c; $m++ ) {
        printf ("%3s<machine>\n");
        printf ("%6s<code>$CODE[ $m ]</code>\n");
        printf ("%6s<type>$TYPE[ $m ]</type>\n");
        printf ("%6s<load>$LOAD[ $m ]</load>\n");

        printf ("%6s<summary>\n");
        for ( $c = 2; $c < $cSIZE[$m]; $c++ ) {
           printf( "%9s<usage type=\"$VALS[1][1][$c]\"");
	   printf( "%1s\t\tvalue=\"$VALS[$m][$rSIZE[$m]][$c]\"/>\n");
        }
        printf ("%6s</summary>\n");

        printf ("%6s<queues count=\"$COUNT[ $m ]\">\n");

        for ( $r = 2; $r < $rSIZE[$m]; $r++ ) {
           printf ("%9s<queue name=\"$VALS[ 1 ][ $r ][ 1 ]\">\n");
           for ( $c = 2; $c <= $cSIZE[$m]; $c++ ) {
              printf ("%12s<usage type=\"$VALS[1][1][$c]\"");
	      printf ("%1s\t value=\"$VALS[$m][$r][$c]\"/>\n");
           }
           printf ("%9s</queue>\n");
        }

        printf ("%6s</queues>\n");
        printf ("%3s</machine>\n\n");
    }
}
    print "</machine_usage>\n";


    close(TEMP);
    @cannot = grep {not unlink} $mach_usagefile;
    die "$0: could not unlink @cannot\n" if @cannot;
