in reply to Re: Using Config::IniFiles Module Obtain Comma Separated Values into An Array
in thread Using Config::IniFiles Module Obtain Comma Separated Values into An Array

Hello Discipulus,

Thank you for taking the time to Notice and Reply :) :).

The Previous set of population was by using
i=abc i=def .... i=wxyz.
This works perfectly fine.

But there is some other Way to populate an array by using space,comma(s),dot(s) by default.

like ...
j=abc def ghi jkl mno pqrs tuv wxyz<br> j=abc,def,ghi,jkl,mno,pqrs,tuv,wxyz<br> j=abc.def.ghi.jkl.mno.pqrs.tuv.wxyz<br>
I need this way of Obtaining he values in an array.

Replies are listed 'Best First'.
Re^3: Using Config::IniFiles Module Obtain Comma Separated Values into An Array
by soonix (Chancellor) on May 27, 2016 at 08:07 UTC

    Config::IniFiles, as many other modules, is meant as a versatile instrument and therefore allows spaces, commas, etc. as part of the configuration values. So you seem to be out of luck.

    Discipulus' hint is the best you can get, except he didn't quote the last sentence of that section:
    A multi-line/value field that is returned in a scalar context will be joined using $/ (input record separator, default is \n) if defined, otherwise the values will be joined using \n.
    So you'd have to decide beforehand which separator to use - EITHER space OR comma OR dot (OR whatever) - and go for something like
    my @arr; { local $/ = ' '; @arr=$cfg->val('hello','j'); }
    $/ is a Perl builtin, see perlvar (search for $RS), so it's not a "third party method".

    Sorry, that was wrong, describing the module's behaviour for returning a multivalue as a scalar. But what's wrong with Corion's suggestion? split is also a Perl builtin, not "third party".

    OR make the multiline field in the ini file conform to the format specified in the "FILE FORMAT" section of the module's documentation…

Re^3: Using Config::IniFiles Module Obtain Comma Separated Values into An Array
by Corion (Patriarch) on May 27, 2016 at 07:28 UTC

    Have you considered using split to split up the values?

      Hello Corion,

      Thanks for the reply :D .

      No I cant,I cannot do that.
      Splitting it by values would get me the result.
      But that's the constraint,
      I cant use Split by values or Regex or Any third Party Methods other than Config::IniFiles.

      This is where it gets Complicated. D: D: D:

        Your requirements make no sense.

        A reply falls below the community's threshold of quality. You may see it by logging in.