Re: Data type of attributes

2016-09-30 Thread Klaus Jantzen
On 09/29/2016 09:54 PM, Chas. Owens wrote: > This is what the meta object is for: > > #!/usr/bin/perl > > { package Foo; > use Moose; > use warnings; > > has num => ( is => "rw", isa => "Int" ); > has str => ( is => "rw", isa => "Str" ); > } > > use strict; > use fea

Re: Data type of attributes

2016-09-29 Thread Илья Рассадин
Hi, claus! Actually, I can't understand the question. You can (and should) define type constraint for attribute via Moose predefined types, Types::Standart module or your own type system. use Types::Standard -all; use Moose; has 'attr_name' => ( 'is' => 'ro', 'isa' => InstanceOf['

Re: Data type of attributes

2016-09-29 Thread Uri Guttman
On 09/29/2016 03:52 PM, Aaron Wells wrote: Hi Klaus, Have you tried this? ref $some_obj; # should give your class name as a string Doubtless Uri will find something wrong with this 😋 glad you asked! :) ref will return the class something is blessed into. reftype (in Scalar::Util) will ret

Re: Data type of attributes

2016-09-29 Thread Chas. Owens
This is what the meta object is for: #!/usr/bin/perl { package Foo; use Moose; use warnings; has num => ( is => "rw", isa => "Int" ); has str => ( is => "rw", isa => "Str" ); } use strict; use feature "say"; use warnings; my $foo = Foo->new; for my $attr ("num"

Re: Data type of attributes

2016-09-29 Thread Aaron Wells
Hi Klaus, Have you tried this? ref $some_obj; # should give your class name as a string Doubtless Uri will find something wrong with this 😋 On Thu, Sep 29, 2016, 12:34 PM Klaus Jantzen wrote: > Hello, > > I have defined Moose-classes with various attributes. > > During the execution of a progr

Data type of attributes

2016-09-29 Thread Klaus Jantzen
Hello, I have defined Moose-classes with various attributes. During the execution of a program that uses such a class I would like to determine the data type of a specific attribute at the time I am using it. How can I do that? -- K.D.J. -- To unsubscribe, e-mail: beginners-unsubscr...@perl