Hi!

I have a Pretty class, with 15 methods (or more). I was reading a Perl 
Tutorial and read that I could create local variables. So In many of my 
methods Im using variables, but Im not declaring them like 'local $var', just 
like 'my $var'. So I changed a few variables from 'my' to 'local', and When I 
tried to see if it was working I got:

[EMAIL PROTECTED] Perl]$ perl Persona.pm
Global symbol "$name" requires explicit package name at Persona.pm line 22.
Global symbol "$name" requires explicit package name at Persona.pm line 24.
Global symbol "$name" requires explicit package name at Persona.pm line 25.
Global symbol "$name" requires explicit package name at Persona.pm line 26.
Execution of Persona.pm aborted due to compilation errors.

The method that I modified:

sub hablar {
    my $person = shift;
    
    local $name;
    print "Give me your second name.. ";
    $name = <STDIN>;
    chop $name;
    print "Your second name is $name\n";
    

    if ($_[0] eq "fuerte") {
        print "My first name is $person->{NOMBRE}!!!\n";
    }
    elsif($_[0] eq "bajo") {
        print "My alias it $person->{NOMBRE}\n";
    }
}

And obviously, 'local $name', was 'my $name' and it was working so nice..

So is it necesary to declare the variables as local vars? Cause Im getting 
errors :(

THankss!
Pablo
-- 
Pablo Fischer Sandoval ([EMAIL PROTECTED])
http://www.pablo.com.mx
http://www.debianmexico.org
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131  AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to