Here is the complete script....

#!/usr/bin/perl
package Handlers::Devices;
use DBI;
use HTML::Template;

use Apache2::RequestRec ();
use APR::Request::Param ();
use Apache2::Const -compile => 'OK';

sub handler {
   my $r = shift;
   my $req = $r->param("chosen_base");
   
   my $template = HTML::Template->new( filename => 
'/home/mitch/www-dev/mod_perl/templates/devices.tmpl' );
   my $switch;
   my $base_abbreviation;
   my @routers;

#   Old way of doing things
#
#   read( STDIN, my $buffer, $ENV{'CONTENT_LENGTH'} );
#   @pairs = split /=/, $buffer;
#   $value = $pairs[1];
#     if( $value =~ m/\+/ ){;
#        $value =~ s/\+/ /g;
#     }
#   my $chosen_base = $value;
   my @loop_data = ();    
   $template->param(BASE => $chosen_base);
   $template->param(DATA => $req );
   SWITCH: {
      if( $chosen_base =~ /Kan/ ) { $base_abbreviation = 'kba'; last SWITCH;}
      if( $chosen_base =~ /29/ ) { $base_abbreviation = 't'; last SWITCH;}
      if( $chosen_base =~ /New/ ) { $base_abbreviation = 'nri'; last SWITCH;}
       if( $chosen_base =~ /San/ ) { $base_abbreviation = 'sdi'; last SWITCH;}
       if( $chosen_base =~ /Che/ ) { $base_abbreviation = 'cpo'; last SWITCH;}
       if( $chosen_base =~ /Par/ ) { $base_abbreviation = 'pai'; last SWITCH;}
       $base_abbreviation = substr( $chosen_base, 0,3 );
   }

   my $dbh = DBI->connect( 'dbi:ODBC:MRIServer2k', 'mriinventory', '[EMAIL 
PROTECTED]',
                           { PrintError  =>  1, RaiseError => 0, AutoCommit => 
1 } );

   my $sql = "select name, location from tblLiveCisco where( name LIKE 
'$base_abbreviation%' )";

   my $sth = $dbh->prepare( $sql );
   $sth->execute();
   my $rows;
   push @{$rows}, $_ while $_ = $sth->fetchrow_hashref();

   $template->param( ROWS => $rows);
   foreach $row( @$rows ) {
       my %router;
       if ( ($row->{name} =~ /rtr/) || ($row->{name} =~ /dsw/) || ($row->{name} 
=~ /csw/) || ($row->{name} =~ /coresw/) ) {
           $router{ROUTER} = $row->{name}; 
           push ( @routers, \%router );
       }
   }

   $template->param( ROUTERS_LOOP => [EMAIL PROTECTED]); 
   print "Content-Type: text/html\n\n";
   
   print $template->output;
   
   return Apache2::Const::OK;
}

1;

Mitchell Raful MCSE CCNP
MCB Quantico
Personal and Family Readiness (MRI)
3044 Catlin Avenue
Quantico, VA 22134
Com: 703-784-5991
DSN: 278-5991
Cell: 804-363-0731


-----Original Message-----
From: Colin Wetherbee [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 02, 2008 3:30 PM
To: Raful Mr Mitchell H
Cc: modperl@perl.apache.org
Subject: Re: segfault


Raful Mr Mitchell H wrote:
> My script looks like this
>  
> use Apache2::Request ();
>  
> my $req = Apache2::Request-> new($r)
> my $data = req->{/param-name}/
> // 
> It causes a segfault error.  Any ideas?

Hello.

Please send us a bit more of your script.  This snippet doesn't say much.

Colin

Reply via email to