The three occurrences of this warning:
Useless use of a constant in void context at libbuilder.pl line 77.
stem from using incorrect syntax for opening the DBI connection to your database. At line 77 of your script, this:
$dbh = ("DBI:mysql:host=localhost; database=blah", "blah", "blah", {PrintError => 0, RaiseError=>1});
should be something like this:
$dbh = DBI->connect( "DBI:mysql:host=localhost;database=blah", $user, $passwd, {PrintError=>0,RaisError=>1});
The other messages all stem from these lines, I think:
$index->{$word} = ( exists $index->{$word} ? "$index->{$word}:" : "" ) . "$file_id" unless $seen_in_file{$word}++;
and there's a lot of trouble there. First, it's good you are using strict, because you declared "index" as a hash ("my %index") but in these lines just cited, your using a scalar variable called "$index", and treating it as a reference to a hash. Make it a hash, or make it a scalar that you use as a hash-ref -- don't do it both ways.

Another problem with those lines is the syntax. I think you want something like this:

if ( ! $seen_in_file{$word} ) { $index{$word} .= ":" if ( exists( $index{$word} )); $index{$word} .= $file_id; $seen_in_file{$word}++; }
Don't try using the ternary operator together with a post-conditional in the same statement -- it's too complicated, and you obviously did it wrong. So just keep it simple and clear.

update: actually, the message about "missing right curly bracket" is because you really are missing a close-curly just before "sub usage" is declared. As mentioned in an earlier reply, you'll benefit from maintaining proper indentation as you edit your code. There are editors that make this relatively easy, once you learn how to use them.


In reply to Re: Finding local vs Global Error by graff
in thread Finding local vs Global Error by Cappadonna3030

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.