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 Anonymous Monk,

I cant get the space separated value.

I need a way to get the j= abc def ghi jkl mno pqrs tuv wxyz
in a single line of code using a method of Config::IniFiles.

like my
@array=$cfg->arrayValBySpace('hello','j')

Note:
not as a single line like abc ... wxzy
but as separate values like $arr[1]= abc , $arr\[[$#arr]=wxyz.
  • Comment on Re^2: Using Config::IniFiles Module Obtain Comma Separated Values into An Array

Replies are listed 'Best First'.
Re^3: Using Config::IniFiles Module Obtain Comma Separated Values into An Array
by Anonymous Monk on May 27, 2016 at 07:38 UTC
    Well, Config::IniFiles doesn't do that, it only supports newlines seperation, so the only way to get it, is to subclass/extend Config::IniFiles or ...
      Please do go on Anonymous Monk.

      I am listening.
      Okay How do I do that...??

      Please share a sample or snippet code if possible.

      Even a link would suffice..

        You have already been shown the link to split. The next step is to apply that function to your code.

        Please note that this is not a script writing service. Your constant asking for "sample or snippet of code" feels to me as if you are unable or unwilling to write any code yourself. This is not what this site is for.

        This site is for and by programmers or people learning how to program, with the central focus on Perl.

        Your problem would be easily solved by writing one additional line of Perl code. You have stated that this is impossible for you, but have not stated at all why this would be impossible for you.

        If your requirements prohibit you from actually programming, this site is not for you.

        hehe, what corion said :)
        package MyConfini; use parent qw/ Config::IniFiles /; sub MyConfini::arrayValBySpace { my( $self, @rest ) = @_; my @vals = $self->val( @rest ); if( @vals == 1 ){ @vals = split ' ', $vals[0]; } return vals; }