File Coverage

lib/Plack/App/WebMySQL/General.pm
Criterion Covered Total %
statement 8 49 16.3
branch 0 8 0.0
condition 0 3 0.0
subroutine 4 8 50.0
pod 0 4 0.0
total 12 72 16.6


line stmt bran cond sub pod time code
1             #the dumb terminal webmysql module
2             #mt 16/11/2003 2.4 added parseFragmentToString
3             package Plack::App::WebMySQL::General;
4             BEGIN {
5 1     1   738 use Exporter();
  1         2  
  1         19  
6 1     1   3 use Plack::App::WebMySQL;
  1         1  
  1         81  
7 1     1   7 @ISA = qw(Exporter);
8 1         462 @EXPORT = qw(getData replace parsePage parseFragmentToString);
9             }
10             ###############################################################################################################
11             sub getData{ #gets cgi form data into a hash
12             #foreach (keys %ENV){print STDERR "$_ = $ENV{$_}\n";}
13 0     0 0   my $cgi = CGI::new();
14 0           %form = (); #empty first as PSGI will keep globals set until the server is killed.
15 0           foreach($cgi -> param()){
16 0           $form{$_} = $cgi -> param($_);
17             #print STDERR "$_ = $form{$_}\n";
18             }
19 0           return 1;
20             }
21             ###############################################################################################################
22             sub replace{ #make sure we dont get any undefined values when replacing template placeholders
23 0 0   0 0   if(defined($form{$_[0]})){return $form{$_[0]};} #return hash value
  0            
24             else{
25 0           print STDERR "$0: $_[0] is undefined in placeholder replace\n";
26 0           return ""; #return nothing
27             }
28             }
29             ###############################################################################################################
30             sub parsePage{ #displays a html page
31 0     0 0   my $page = shift;
32 0           my $ignoreError = shift;
33 0 0 0       if($error && !$ignoreError){ #an error has not been encountered and we are not ignoring it
34 0           $page = "error";
35 0           print STDERR "$0: $error\n"; #log this error too
36             }
37 0 0         if(open(TEMPLATE, "
38 0           while(