OK, you're on a unix box, so using "chop" instead of "chomp" is not a problem (but it is depricated, IIRC). I think you made a mistake copying the code into the post -- there's a problem in the section shown below, which I have commented (but if the code really looks like this, maybe this is part of the problem):
foreach $loop (sort `cd $data_dir; ls -d *`) { chop($loop); foreach $loop2 (sort `cd $data_dir; ls -d $loop/*`) { chop($loop2); ### foreach $loop3 (sort `cd $data_dir; ls -d $loop2/*`) { ## should be: ## foreach $loop3 (sort `cd $data_dir/$loop; ls -d $loop2/*`) { ## or: foreach $loop3 (sort `cd $data_dir; ls -d $loop/$loop2/*`) { chop($loop3); ## BTW, this: $all_files[$i++]=$loop3; ## should be: push( @all_files, $loop3 ); } } }
Apart from that, you're doing  $data_path = s/[\n\r]//g; which seems unnecessary -- you already chopped it in the loop above, and it's just a line of output from "ls".

Then you're splitting $data_path on slash characters, which would never be present in $data_path given the code as posted, so $blank and $file are always empty strings, I think.

I didn't see where &get_key_field() is defined; are you confident about what it's return value is, or should you be testing that?

I'm sorry if this is all peripheral to the real problem, but I think it's worth looking into -- try "perl -d" on the script, set some breakpoints at key lines, and step through it to see whether the values of the variables match your expectations.


In reply to Re: Error creating database file by graff
in thread Error creating database file by krivenburg

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.