in reply to Sharing a variable between (>=) 2 files

Try:
##### start of settings.pl ##### our %default_settings = ( verbose => 1, debug => 0, help => 0, game => "etqw" ); ##### end of settings.pl #####
Using $verbose => 1 etc will use the value of the variable $verbose as a key, instead of the string "verbose" which is what you probably want.

Replies are listed 'Best First'.
Re^2: Sharing a variable between (>=) 2 files
by dichtfux (Sexton) on Nov 30, 2007 at 22:56 UTC
    Omg, you're right, that solved it. I feel a bit ashamed now - especially since that was my first question here.

    For future reference: using 'our' works, only problem with the code was that I was too stupid to use an assoc array in Perl. :(

    Thanks a lot!



    Btw: Do I now have a reputation of -1 because my question sucked or simply because I asked 1 question and answered 0 so far (and 0 - 1 = -1)?
      The "real" problem is, that using 'strict' and 'warnings' does not influence require()d files, so references to unused variables in your require()d file don't give warnings or errors.

      Btw: Do I now have a reputation of -1 because my question sucked or simply because I asked 1 question and answered 0 so far (and 0 - 1 = -1)?
      If you mean, why has your post a rep of -1, it probably means 1 of the "regulars" downvoted your post for some reason and none of them bothered to upvote it.

      Don't worry too much about it unless you get below -5 or so. Large (positive or negative) XP values indicate a sort of consensus. Small XP values change a lot.

        The "real" problem is, that using 'strict' and 'warnings' does not influence require()d files, so references to unused variables in your require()d file don't give warnings or errors

        True. I played around a bit with the code yesterday and also noticed that. When I added 'use strict' to settings.pl, I got a bunch of warnings with the old (wrong) code.
      Btw: Do I now have a reputation of -1 because my question sucked or simply because I asked 1 question and answered 0 so far (and 0 - 1 = -1)?

      Your node has a reputation. Users get levels which are based on how many experience points they have (like in Dungeons & Dragons and several other role-playing games that followed its lead).

      Don't beat yourself up too much -- to the person that wrote the code it looks correct so the bug gets glossed over. It is almost a prerequisite that a second pair of eyes is needed to catch this kind of bug.