Okey here is the code for the 1st of 3 parts of my question thati wrote:
my @files = glob "$ENV{'DOCUMENT_ROOT'}/data/text/*.txt"; my @filenames = map {/([^\/]+)\.txt$/} @files; my @dbfiles = $db->do( 'SELECT title, body FROM articles' ); my $replace = $db->prepare( 'INSERT INTO article (title, body) VALUES +(?, ?)' ); foreach $filename (@filenames) { #Check every filename(item in @menu_files) as well as its content t +o see if is already inserted in table articles under columns title an +d body #============ INSERT NEW FILENAMES & CONTENTS INTO DATABASE IF ANY +============= #If filename and content dont already exist in the db then do inser +t them unless( grep /^\Q$filename\E$/, @dbfiles ) { open FILE, "<$filename" or die $!; @data = <FILE>; close FILE; unless( grep /^\Q$data\E$/, @dbfiles ) { $db->do('INSERT INTO articles (title, body) VALUES (?, ?)', u +ndef, $filename, $data) } } }
I know i have syntax errors and the array @dbfiles it snot filled correctly but at least i tried.

What i try to do each open each filename and check to see if there is an already column name in the db for that filename, if it is iam also checking for the filenames content to see if it matched the 'body' column of the db

Here is the definition of mysql table articles which is supposes to hold the filenames and their contents.

$db->do( 'CREATE TABLE articles (id tinyint auto_increment primary k +ey, title varchar(100), body text)' );
I believe the logical of the code its correct its the syntax part iam having trouble with.

In reply to Re^4: Inserting, update and deleteting a database under conditions by Nik
in thread Inserting, update and deleteting a database under conditions by Nik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.