http://www.perlmonks.org?node_id=923569

sowraaj has asked for the wisdom of the Perl Monks concerning the following question:

i need to make faster execution of this code by using bulk loader

i can't able to understand the bulkloader package source code properly.

I need to enhance this code by using bulk loader; i thought it will rapidly reduce the time of process.

I request you to modify this code by using bulk loader concept

At present i use ubuntu and mysql platform

======== SCHOOL (B): MALE ========= SCHOOL_NAME :ABCDEFGH NAME_OF_STUDENT :RAJ ID_NUMBER :9632587410 ADDRESS :23,7TH STREET PINCODE :03214 MOBILE_NUMBER :4563210789 LAND_LINE :0123859674 FATHER'S_NAME :SHIVA MOTHER'S_NAME :JAYA ANNUAL_INCOME :520000 CHARACTER :GOOD ======== SCHOOL (G): GIRLS ========= SCHOOL_NAME :QWERTY NAME_OF_STUDENT :FATEMAH ID_NUMBER :10234567890 ADDRESS :635,9TH STREET PINCODE :63520 MOBILE_NUMBER :9632105478 FATHER'S_NAME :NHOORE MOTHER'S_NAME :JAVATHI ANNUAL_INCOME :420000 CHARACTER :GOOD #PLS NOTE THAT THE LAND_LINE NUMBER OF GIRLS SCHOOL IS MISSING #!/usr/bin/perl use strict; use warnings; use DBI; my $table = 'SOWND1'; my $dbh = DBI->connect( 'dbi:Mysql', 'new', undef, { PrintError => 0, + RaiseError => 1 } ); my $sth = $dbh->prepare("DROP TABLE IF EXISTS '$table'"); $sth->execute; $sth = $dbh->prepare( "CREATE TABLE $table( TYPE varchar(300), SCHOOL_NAME varchar(300), NAME_OF_STUDENT varchar(300), ID_NUMBER varchar(300), ADDRESS varchar(300), PINCODE varchar(300), MOBILE_NUMBER varchar(300), LAND_LINE varchar(300), FATHERS_NAME varchar(300), MOTHERS_NAME varchar(300), ANNUAL_INCOME varchar(300), CHARACTER varchar(300) )" ); $sth->execute; $sth = $dbh->prepare("INSERT INTO $table VALUES(?,?,?,?,?,?,?,?,?,?,?, +?)"); my @files = <C:/strawberry/perl/bin/SCHOOL/STUDENTS/*>; die "No files found\n" unless scalar @files; for my $infile (@files) { local $/ = ''; open my $fh, '<', $infile or die "$!\n"; while (my $record = <$fh>) { chomp $record; my %info; $record =~ s/^=+.+ MALE =+/TYPE :BOYS/; $record =~ s/^=+.+ GIRLS =+/TYPE :GIRLS/; map { my ( $key, $value ) = split / :/, $_; $key =~ s/\'//g; $info{$key} = $value; } split /\n/, $record; $info{LAND_LINE} ||= 'NE'; $sth->execute( $info{TYPE}, $info{SCHOOL_NAME}, $info{NAME_OF_STUDENT}, $info{ID_NUMBER}, $info{ADDRESS}, $info{PINCODE}, $info{MOBILE_NUMBER}, $info{LAND_LINE}, $info{FATHERS_NAME}, $info{MOTHERS_NAME}, $info{ANNUAL_INCOME}, $info{CHARACTER} ); }; }