Soy demasiado novato en esto y necesito ayuda.
Mi problema es que al intentar hacer una clase derivada, heredo de su clase padre, intento definir las nuevas propiedades de la clase derivada y al testear el programa me tira el error "global symbol "$self" requires explicit package at "alumno.pm" at line 35.
El código de alumno es el siguiente:
Using perl Syntax Highlighting
- #! /usr/bin/perl
- package Alumno;
- use Persona;
- @ISA=qw(Persona);
- use strict;
- sub new{
- my $this=shift;
- my $class= ref($this) || $this;
- my $self=$class->Persona::new("Persona");
- $self->{_nstudent}=0;
- $self->{_cal_inter}=0;
- $self->{_cal_database}=0;
- $self->{_cal_diferenciales}=0;
- $self->{_cal_circuitos}=0;
- $self->{_cal_bio}=0;
- $self->{_cal_diseno}=0;
- bless $self, $class;
- return($self);
- }
- sub setidstudent {
- my ( $self, $idstudent ) = @_;
- $self->{_nstudent} = $idstudent if defined($idstudent);
- return $self->{_nstudent};
- }
- sub getidstudent{
- my( $self ) = @_;
- return $self->{_nstudent};
- }
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4
Los errores que salen son los siguientes:
syntax error at Alumno.pm line 34, near "$self"
syntax error at Alumno.pm line 40, near "}"
Global symbol "$class" requires explicit package name at Alumno.pm line 42.
syntax error at Alumno.pm line 45, near "}"
Can't use global @_ in "my" at Alumno.pm line 51, near "= @_"
Global symbol "$idstudent" requires explicit package name at Alumno.pm line 52.
Global symbol "$idstudent" requires explicit package name at Alumno.pm line 52.
syntax error at Alumno.pm line 54, near "}"
Can't use global @_ in "my" at Alumno.pm line 58, near "= @_"
syntax error at Alumno.pm line 61, near "}"
Alumno.pm has too many errors.
Compilation failed in require at ./sinquehacer.pl line 4.
BEGIN failed--compilation aborted at ./sinquehacer.pl line 4.
Tengo más métodos iguales de set() y get(), asé que si resuelvo esto supongo que los siguientes se resolverían de la misma manera.
De antemano, gracias, espero su pronta respuesta