#!/afs/athena/contrib/perl5/p

use strict;

package Foo;
use vars qw( $cheese $ham $pickle );
$cheese=1;
$ham=5;
$pickle=9;

sub new {
  my $class = shift;
  bless [ @_ ], $class;
}
sub px {
  my $self = shift;
  printf "%s cheese = %d\n", ref($self), $cheese;
  printf "%s ham =    %d\n", ref($self), eval "\$@{[ref($self)]}::ham";
}
sub py {
  my $self = shift;
  {
      no strict 'refs';
      printf "%s pickle = %d\n", ref($self), $pickle;
  }
}
sub qx {
  my $class = shift;
  printf "%s selfo =  %d\n", $class, $class->[0];
  printf "%s cheeso = %d\n", $class, $cheese;
  printf "%s hamo =   %d\n", $class, eval "\$${class}::ham"
    unless ref($class);
}

package Bar;
use vars qw( @ISA $cheese $ham );
@ISA = qw( Foo );
$cheese = 2;
$ham = 6;

sub py {
  my $self = shift;
  {
      no strict;
      printf "%s pickle = %d\n", ref($self), $pickle;
  }
  $self->SUPER::py;
}

package main;

my ($a) = new Foo 1,2,3;
$a->px;
$a->py;
$a->qx;
Foo->qx;

my ($b) = new Bar 'a','b';
$b->px;
$b->py;
