Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    my $TMPL_FILE    = '/path/to/template';
    my $DB_FILE      = '/path/to/flat_file';
    my $DB_SEPERATOR = '\|';
    
  2. or download this
    my @DB_FIELDS = (
        [ 'num1',   \&INTEGER,     1 ], 
        [ 'text1',  \&WORD,        0 ], 
        [ 'email',  \&EMAIL,       1 ], 
    );
    
  3. or download this
    my %SEARCH  = (
        num1  => [ param("num1"),   \&INTEGER ], 
        email => [ param("email"),  \&EMAIL   ], 
    );
    
  4. or download this
    my $RESULTS_PER_PAGE  = param('RESULTS_PER_PAGE') || 0;  # 0 means inf
    +inate
    my $MAX_RESULTS       = 0;   # Also infinate
    my $PAGE_NUMBER       = param('PAGE') || 0;  # Pagin numbering starts 
    +at 0
    
  5. or download this
    my $search  = CGI::Search->new(
        script_name      => $ENV{SCRIPT_NAME}, # Script location on web si
    +te--for paging
    ...
    
        search_fields    => \%SEARCH,          # Referance to search field
    +s
    );
    
  6. or download this
    my @data  = $search->result(1) or die "Error: " . $search->errstr;
    my $tmpl  = $search->result(1) or die "Error: " . $search->errstr;
    
  7. or download this
    my %new_search = (
        num1  => [ param("num1"),        \&INTEGER ], 
    ...
    );
    
    my $new_tmpl = $search->result(1, \%new_search);
    
  8. or download this
    <TMPL_UNLESS NAME="error">
        <!-- This will show if there were no problems with the overall sea
    +rch -->
    ...
        <h1><TMPL_VAR NAME="error"></h1> <!-- a short error message -->
        <p><TMPL_VAR NAME="errstr"></p>  <!-- a more descriptive error mes
    +sage -->
    </TMPL_UNLESS>
    
  9. or download this
    my $custom_validator = sub 
    {
    ...
            return (0, undef, "$_[0] is not valid");
        }
    };
    
  10. or download this
    my @DB_FIELDS = (
        [ 'num1',    $custom_validator,  1 ], 
        [ 'email',   \&EMAIL,            0 ], 
        ...
    );