Hosen1989 has asked for the wisdom of the Perl Monks concerning the following question:
Dear ALL,
I need to add array of data to my class (using Moose) and be able to read it inside me class, I thinks something like this:
here I many use different @parserArray_type_xx with each different file depend on its type to parse it.
so my Q is: How to do it?
<pEdit:###############################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
package DataDecoder; use Moose; ... #######need to add something like this####### my @parserArray_type_01 = ( ... { name => 'YEAR', type => 'CHAR', len => 2, description => sub{0} }, { name => 'MONTH', type => 'CHAR', len => 2, description => sub{0} }, { name => 'DAY', type => 'CHAR', len => 2, description => sub{0} }, { name => 'HOUR', type => 'CHAR', len => 2, description => sub{0} }, { name => sub{ my $data = uc shift; my %SUD_DATA = ('98' => 'TYPE1', '64' => 'TYPE2'); ); (defined $SUD_DATA{$data})? $SUD_DATA{$data} : $data # $data }, type => 'HEX', len => 1, description => sub{ my $data = uc shift; my %SUD_DATA = ('98' => 'TYPE1', '64' => 'TYPE2'); (defined $SUD_DATA{$data})? $SUD_DATA{$data} : $data # $data }, } ); ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: defined class variable with Moose
by kcott (Archbishop) on Jun 26, 2015 at 19:01 UTC | |
by Hosen1989 (Scribe) on Jun 26, 2015 at 20:02 UTC | |
by kcott (Archbishop) on Jun 26, 2015 at 21:17 UTC | |
|
Re: defined class variable with Moose
by kevbot (Vicar) on Jun 27, 2015 at 04:36 UTC |