Hi,

I am running ASPerl 5.6.1 on Windows 2000 using Apache as the web server. I need a quick solution to display a page while our production Helpdesk has it's legs in the air. This solution may need to be used again in the future, so I would like to start with a quick win but expand this into something more a little later.

The Problem: I have an automated process that creates small xml files in several dirs. These files can number upwards of 200 files per dir and about 7 dirs.

home/
dirA/
dirB/
dirC/

Each XML file looks similar to the following:

<?xml version="1.0"?> <opt> <Agent_Class>Backup</Agent_Class> <MD>dirA</MD> <Agent_Instance>NetBackup</Agent_Instance> <Date>2003/12/08</Date> <Server>ServerABC</Server> <Instance_Detail>Backup Problems ServerABC:57</Instance_Detail> <Time>08:04:58</Time> <Header>X-CALL</Header> <State>CRITICAL</State> </opt>

Basically I need to display a table with the dir name and some of the contents of all the files in its dir. Something like:

Managing ServerCall Details
dirA
ServerABC - Backup - NetBackup - Backup Problems ServerABC:57
ServerDEF - Drive - Space - Drive C: is out of disk space

This is a snippet of what I have at the moment which is proving FAR too slow:
if (opendir (DIR, $path)) { while( my $dir = readdir( DIR ) ) { next if( ( "." eq $dir ) || ( ".." eq $dir ) ); if (-d "$path/$dir") { print "<TR><TD>$dir</TD><TD></TD></TR>\n"; print "<TR><TD>$dir</TD>\n"; if (opendir (CUSTDIR, "$path/$dir")) { my $count = 0; while (my $file = readdir( CUSTDIR)) { next if (("." eq $file) || (".." eq $file)); $count++; if (eval { $callvals = XMLin("$path/$dir/$file") } +) { # $calldetails{$callvals->{Server}} = "$callval +s->{State} $callvals->{Agent_Class} $callvals->{Agent_Instance} $call +vals->{Instance_Detail}"; print "<TR><TD></TD><TD><B>$callvals->{Server} +</B> - $callvals->{State} - $callvals->{Agent_Class} - $callvals->{Ag +ent_Instance} - $callvals->{Instance_Detail}</TD></TR>\n"; } else { die "Cannot Read $path/$dir/$file: $@\n"; } } close (CUSTDIR); print "<TD>$count XML files</TD></TR>\n"; } else { die "Cannot find path $path/$dir: $!\n"; } } } close(DIR); } else { die "Cannot find path $path: $!\n"; }
I thought of putting all the data from the files into a hash so I only had to process the relevant bits when I build the web page.

What can I do to be able to read these files and put some of the detail in a web page before the web page times out or tries to refresh itself (120 Secs)?

It must be said that I am using CGI, but that cgi/html is NOT where my little experience lies..

-----
Of all the things I've lost in my life, its my mind I miss the most.

In reply to Fast processing of XML files for CGI by AcidHawk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.