in reply to Re: defined class variable with Moose
in thread defined class variable with Moose

Hi there,

Thanks for you reply.

I can see that my code hare are somewhat confusing, but I use description => sub{0} in-stand of description => 0 to keep the consist with other item in my @parserArray, as i need them to be in the same format where i use each item in this array to read some part of my raw file.

As my question here was not clear,let me ask again: but what i need to do is to define variable in my class that contain some predefined data (mix of array/hash/scalar/code).

BR

Hosen

Replies are listed 'Best First'.
Re^3: defined class variable with Moose
by kcott (Archbishop) on Jun 26, 2015 at 21:17 UTC
    "but I use description => sub{0} in-stand of description => 0 to keep the consist with other item in my @parserArray, ..."

    I only said "you could just use", not "you must use". That was just a suggestion. By all means, keep them consistent.

    The main thrust of what I was pointing out, was that a value of 'sub { 0 }->()', or just a plain old '0', will evaluate to 0; however, the 'sub { 0 }' that you showed evaluates to something like CODE(0x7f8c34026a60).

    "... what i need to do is to define variable in my class that contain some predefined data"

    Isn't @parserArray_type_01 just such a variable with predefined data?

    I don't see a reason why you can't use something like $parserArray_type_01[$index]{$key} in your code (whether it uses Moose or not).

    Please post a short piece of code (10-20 lines) that demonstrates where such a variable is causing problems.

    -- Ken