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 }, } ); ...
In reply to defined class variable with Moose by Hosen1989
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |