package C; use strict; use base qw(model type); 1; __END__ $ perl -e 'use C' Base class package "model" is empty. (Perhaps you need to 'use' the module which defines that package f +irst.) at C.pm line 5 BEGIN failed--compilation aborted at C.pm line 5.
Working code to scrutinize would help to help.
Apart from that, you might want to have a look at Spiffy.
package A; use Spiffy -Base; use strict; field $_ for qw(id name); sub new { bless {}, $self }
package B; use A -Base; use strict; field $_ for qw(addr phone city); sub new { bless {}, $self }
package C; use A -Base; use strict; field $_ for qw(model type); sub new { bless {}, $self }
#!/usr/bin/perl use strict; use B; use C; use Data::Dumper; $Data::Dumper::Indent = 1; my $foo = new C; $foo->id(123); $foo->name("thingy"); $foo->model("Z80"); my $bar = new B; $bar->id(456); $bar->city("Lhasa"); $bar->name("kouxuan"); print Dumper($foo); print Dumper($bar); __END__ $VAR1 = bless( { 'model' => 'Z80', 'name' => 'thingy', 'id' => 123 }, 'C' ); $VAR1 = bless( { 'city' => 'Lhasa', 'name' => 'kouxuan', 'id' => 456 }, 'B' );
Spiffy rocks ;-)
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Cross reference between two classes and FIELDS
by shmem
in thread Cross reference between two classes and FIELDS
by nite_man
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |