#!/usr/bin/perl use DBI; use strict; use warnings; # DEFAULT SCRIPT USER our $db_user_name = 'root'; # DEFAULT PASSWORD FOR SCRIPT USER our $db_password = '[mysql_root_password_here]'; our $database = "Bibles"; our $table = "KJV"; our $DEBUG=0; # Treat all input and output as UTF-8 and set the flags correctly # Because _everyone_ should be using UTF8 these days! binmode STDOUT, ":utf8"; binmode STDERR, ":utf8"; binmode STDIN, ":utf8"; ################# #begin my @results = &read_table_from_DB; &processResults(@results); exit; #end ################# sub processResults { my @data = @_; my ($record, $booknum, $chapternum, $versenum, $text) = ('', '', '', '', ''); #OPTIONAL FORM OF ITERATION: # JUST KEEP IN MIND THAT ARE FIVE (5) # RECORDS FOR EACH "ROW" while (@data) { $record = shift @data; $booknum = shift @data; $chapternum = shift @data; $versenum = shift @data; $text = shift @data; #CODE TO ANALYZE AND COMPARE AMONG TEXTS #print $record."\n"; #WILL GENERATE CONSIDERABLE TEXT TO SCREEN } } #END SUB processResults sub read_table_from_DB { my @results = (); my ($record, $booknum, $chapternum, $verse, $text, $other) = ('', '', '', '', '', ''); my $line = ''; my $count = 0; my $statement = qq|SELECT * FROM $table;|; @results = &connectdb($statement); } #END SUB read_table_from_DB sub connectdb { if ($DEBUG==9) {print "sub connectdb: \n"}; my $statement = shift @_; my $dsn = shift @_ || "DBI:mysql:$database:localhost"; my @results = (); my $dbh = DBI->connect($dsn, $db_user_name, $db_password, { mysql_enable_utf8 => 1 }) or die "Can't connect to the DB: $DBI::errstr\n"; my $quest = $dbh->prepare($statement, { RaiseError => 1 }) or die "Cannot prepare statement! $DBI::errstr\n"; if ($DEBUG>0) { $quest->execute() or die qq|CONNECT DATABASE Statement: \n $statement \n \n Error in first database statement! \n $DBI::errstr \n |; } else { $quest->execute() }; while(my @row = $quest->fetchrow_array()) { foreach my $item (@row) { push @results, $item; } } return @results; } # END SUB connectdb