in reply to Re: Storable for user preferences
in thread Storable for user preferences

That way users can see and edit their config values using a text editor

Our users would struggle to use a test editor! The only way the preferences will be updated is from a Perl script under my control prompted by user input on a webpage.

I did consider using JSON or similar, but that means reading in the entire set of preferences every time I want to access just one of them. Not a deal breaker, but it would probably be better if I didn't have to. Yes, te preferences will be all integers and perhaps strings, mostly just binary options so I shall have a look at Config::Any as a solution. thanks.

Replies are listed 'Best First'.
Re^3: Storable for user preferences
by afoken (Chancellor) on Oct 04, 2023 at 12:30 UTC
    I shall have a look at Config::Any as a solution

    If you are using some kind of web environment (e.g. CGI), be VERY careful with write access to the configuration. You need to ensure that no process reads the config file while it is rewritten, or else some settings may get lost. You also need to ensure that at most one process writes the config file at any time. Both can be handled with file locking and atomic renames, but it is easy to implement wrong. It is WAY easier and safer to put the configuration in the database that you already use.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      It is WAY easier and safer to put the configuration in the database that you already use.

      Yup!
      I've gone for a DB solution and it is working well...

      I guess Storable was a case of Shiny Module Sydrome!

        I guess Storable was a case of Shiny Module Sydrome!

        It has its uses. You just have to understand the problem arena. You did well by asking for advice. This wasn't a good use case for Storable and I'm glad you listened to seasoned feedback.

Re^3: Storable for user preferences
by swl (Prior) on Oct 03, 2023 at 22:46 UTC

    Not a problem. Reading the other posts on the thread it seems the prefs will be stored centrally anyway, in which case the database approaches would seem the better fit.