Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/perl/bin/perl #use strict; #commented out for testing propose only use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); use DBI; use XML::XPath; use XML::XPath::XMLParser; my $q = new CGI; print header(); my $transac = $q->param('transac'); my $get_file_from = $q->param('get_file_from'); my $get_file_to = $q->param('get_file_to'); if($transac eq "parse_now"){ &parse_now; }else{ &main; } sub main{ print "Start Main:<br><br>"; print " <table border=\"1\" width=\"600\" cellspacing=\"0\" cellpadding +=\"0\"> <tr><form name=\"xmlform\" action=\"get_node.pl\" method=\"GET +\"> <input type=\"hidden\" name=\"transac\" value=\"parse_now\ +"> <td>Check Policies from: </td> <td><div align=\"center\"> <select name=\"get_file_from\">"; my $dir = '/xml'; opendir(DIR, $dir) or die $!; while (my $file = readdir(DIR)) { # We only want files next unless (-f "$dir/$file"); # Use a regular expression to find files ending in .xml next unless ($file =~ m/\.xml$/); # change to the date format if needed $file=~/(.*?)_(\d{4})(\d{2})(\d{2})_(.*?)/; my $year= $2; my $month= $3; my $day = $4; print "<option value=\"$file\">$file</option>"; } closedir(DIR); #exit; print " </select> </td> <td> to </td> <td><div align=\"center\"> <select name=\"get_file_to\">"; my $dir = '/xml'; opendir(DIR, $dir) or die $!; while (my $file = readdir(DIR)) { # We only want files next unless (-f "$dir/$file"); # Use a regular expression to find files ending in .xml next unless ($file =~ m/\.xml$/); # change to the date format if needed later $file=~/(.*?)_(\d{4})(\d{2})(\d{2})_(.*?)/; my $year= $2; my $month= $3; my $day = $4; print "<option value=\"$file\">$file</option>"; } closedir(DIR); #exit; print " </select> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td align=\"right\"><input type=\"submit\" value=\"Send\"></td> </tr></div> </table></form>"; } # End Sub Main sub parse_now{ # change to the date format if needed later $get_file_from=~/(.*?)_(\d{4})(\d{2})(\d{2})_(.*?)/; my $year= $2; my $month= $3; my $day = $4; my $x_file = "/xml/$get_file_from"; my $xp = XML::XPath->new(filename => $x_file); # more stuff here ........ exit; } #end sub parse now
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Range File Open
by stiller (Friar) on Mar 04, 2008 at 14:17 UTC | |
by Anonymous Monk on Mar 04, 2008 at 14:24 UTC | |
by amarquis (Curate) on Mar 04, 2008 at 14:33 UTC | |
by Anonymous Monk on Mar 04, 2008 at 14:49 UTC | |
by amarquis (Curate) on Mar 04, 2008 at 17:02 UTC | |
by stiller (Friar) on Mar 04, 2008 at 14:38 UTC | |
|
Re: Range File Open
by Anonymous Monk on Mar 04, 2008 at 15:37 UTC | |
|
Re: Range File Open
by Jenda (Abbot) on Mar 05, 2008 at 23:08 UTC |