Help for this page

Select Code to Download


  1. or download this
    sub UNIVERSAL::new {
      my $class = caller() . "::" . shift;
      $class->new(@_);
    }
    
  2. or download this
    package A::B::C;
    sub new { print "A::B::C new @_\n" }
    ...
    # C->new calls UNIVERSAL::new('C', 10)
    # caller() returns 'A::B' (the package we were in)
    # UNIVERSAL::new calls A::B::C->new(10)
    
  3. or download this
    sub UNIVERSAL::new {
      my $pkg = shift;
    ...
      my $new = $class->can('new');
      return $class->$new(@_) if $new != \&UNIVERSAL::new;
      die qq{Can't locate object method "new" via packages $pkg or $class 
    +at $file line $line.\n};