I'm used to having a CONFIG section in each of my scripts but when my projects get to be like 10 separate files I think enough is enough and this is when I want to create a main config file and call it from within my scripts.

This is the first time I've ever tried to use a config file like this and naturally it doesn't work.

In my login.pl script I have

require("config.pl") or die "error: $!";
In my config.pl script (which is in the same folder, I have
####### # MySQL section ####### my $dbase = "estre_test"; my $mysql_user = "estre_admin"; my $mysql_pass = "pass";
And it errors out with
Global symbol "$dbase" requires explicit package name at login.pl line + 32. Global symbol "$mysql_user" requires explicit package name at login.pl + line 32. Global symbol "$mysql_pass" requires explicit package name at login.pl + line 32. Execution of login.pl aborted due to compilation errors.
I'm not sure what I'm doing wrong. The OR DIE isn't catching so I'm assuming it can find the file BUT I used a filename that I knew didn't exist and it DID NOT FAIL. So I have absolutely no idea what's wrong. All the files are in the same folder and chmoded to 755.

Can you my variables in a central config file (that's what I'm trying to do)?.

Thanks for your help


In reply to requiring files by Anonymous Monk

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.