Hi!

I'm trying to create a new class based in a class that use Object::InsideOut. But the new class can't use the Object::InsideOut.

In the child class I do:

sub new { my ($class,%args) = @_; my $new_object = $class->SUPER::new(%args); ....
but, apparently, the new of the base class it's never called.

What I'm missing?

many thanks

execution and code ...

$ perl t2.pl I'm in the child_class new my super is class_insideout id: 1 Use of uninitialized value in array element at /home/glide/develop/per +l_tests/Object_InsideOut/class_insideout.pm line 27. Use of uninitialized value in concatenation (.) or string at /home/gli +de/develop/perl_tests/Object_InsideOut/class_insideout.pm line 27. name: Use of uninitialized value in array element at /home/glide/develop/per +l_tests/Object_InsideOut/class_insideout.pm line 28. Use of uninitialized value in concatenation (.) or string at /home/gli +de/develop/perl_tests/Object_InsideOut/class_insideout.pm line 28. address:
base class code
package class_insideout; use strict; use warnings; { use Object::InsideOut; my @name :Field :Arg(Name => 'name', 'Mandatory' => 1) :Std(Name => 'name'); my @address :Field :Arg(Name => 'address', 'Mandatory' => 1) :Std(Name => 'address'); sub _init :Init{ my ($self,$args) = @_; warn("I'm in the ".__PACKAGE__ ." _init\n"); return; } sub write { my ($self) = @_; print "name: ". $name[$$self] ."\n"; print "address: ". $address[$$self] ."\n"; } } 1;
child class code
package child_class; use strict; use warnings; use Class::Std::Utils; use base qw(class_insideout); { my %num_ID; sub new { my ($class, %args) = @_; my $new_object = $class->SUPER::new(%args); warn("I'm in the ".__PACKAGE__." new\n"); warn("my super is @child_class::ISA \n"); $num_ID{ident $new_object} = $args{id}; return $new_object; } sub write { my ($self) = @_; print "id: ". $num_ID{ident $self} ."\n"; $self->SUPER::write(); return; } } 1;
script code
use strict; use warnings; use FindBin; use lib $FindBin::Bin; use child_class; my $person = child_class->new(id=>1,name=>'aaa',address=>'bbb') or die +(); $person->write();

In reply to Object::InsideOut and $obj->SUPER (fixed) by glide

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.