#!f:/Perl/bin/perl.exe use DBI; use CGI::Lite; use CGI::Carp qw(fatalsToBrowser); use DBIx::Dump; my %data = $cgi->parse_form_data; ##read values that are passed #print distinct values of values of a db. #if values are not passed end... else call the subroutine -> display_data() sub display_data { ##Write to Excel ## my $sth = $dbh->prepare("SELECT devicename,cadb,substatus,dns,ping,snmp,dsiname,ovpi_st,sat,nnm,fqdn FROM consolidated_data where cadb like '$cadb_pass' and substatus like '$substatus_pass' and dns like '$dns_pass' and ping like '$ping_pass' and snmp like '$snmp_pass' and ovpi_st like '$ovpi_st_pass' and sat like '$sat_pass' and nnm like '$nnm_pass' ORDER BY rowid"); $sth->execute() or die "Cannot execute sth: $DBI::errstr"; my $out = DBIx::Dump->new('format' => $format_pass, 'output' => $filename_pass, 'sth' => $sth); $out->dump( ); $sth->finish(); ###This above code works when used as stand alone code### #run the same query { print the results } $sth->finish(); $dbh->disconnect(); }