#MsSQL Server2008 #!/usr/bin/perl use strict; use DBI; my $FIRST="+++++++++++School(B)"; my $SECOND="+++++++++++School(G)"; my $j=0; my $dbh = DBI->connect('dbi:ODBC:SQLServer', undef, undef, {PrintError => 0, RaiseError =>0}); my $sth1 = $dbh->prepare("CREATE TABLE test11 ('$Type[0]','$Students[1]','$class[2]','$Teachers[3]','$hostel[4]')"); $sth1->execute; foreach $line () { chomp $_; ($event[$kk],$data[$kk])=split(/: /,$line); $l= ++$kk; } while($j<=$l) { if($event[$j] eq $FIRST) { $Type[0]="BOYS"; my $x=1; ++$j; } if($event[$j] eq $SECOND) { $Type[0]="GIRLS"; ++$j; } if($event[$j] =~ m/^No.of Stud /ig) { $Students[1]=$data[$j]; ++$j; } if($event[$j] =~ m/^No.of class /ig) { $class[2]=$data[$j]; ++$j; } if($event[$j] =~ m/^No.of teach/ig) { $teachers[3]=$data[$j]; ++$j; } if($event[$j] =~ m/^Hostelfacility/ig) { $hostel[4]=$data[$j]; ++$j; } my $sth = $dbh->prepare("insert into test11 values('$Type[0]','$Students[1]','$class[2]','$Teachers[3]','$hostel[4]')"); $sth->execute; ++$j; } #i need to enhance my coding efficiency pls help me #Thanks in advance