#!/usr/bin/perl -w use strict; use warnings; use DBI; my $username = ""; # Username to include in posts my $dblocation = "./shomble/posts.db"; #needs to point to the relative or absolute # system path of the posts.db file. my $post = ""; my $db = DBI->connect("DBI:SQLite:dbname=$dblocation", "", "", { RaiseError => 1}) or die $DBI::errstr; TRYAGAIN: print "Ok, what would you like to submit?\n>"; $post = ; chomp $post; print "Confirming this is your post:\n".$post."\n Is this correct? (you must type y or yes to submit)\n>"; if ( =~ /y(es)?/i ) { #this needs to be called right before the post is submitted to the database. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); my $timeStamp = sprintf("%.2d/%.2d/%.4d %.2d:%.2d:%.2d", $mday, ($mon + 1), ($year + 1900), $hour, $min, $sec; my $statmentHandle = $db->prepare('INSERT INTO posts VALUES( ?1, ?2, ?3)') or die $DBI::errstr; $statmentHandle->execute( $timeStamp, $username, $post ) or die $DBI::errstr; print "Post submitted, thank you for using Shombler!"; } else { goto TRYAGAIN; } $db->disconnect();