Hello, 

I am trying to use Objects in Perl, and am having some basic problem. 
I am sure I am missing something, but am not able to figure out what.

---

package A

use strict;

my @arr;

sub new
{
    my $classname = shift;
    my $self = {
                 'cfg_file' => undef,
                 @_,
               };

    # Mark it of the right type
    bless ($self, $classname);

    # Initialize the arrays
    my $i = 0;
    for ($i = 0; $i < 4; $i += 1) {
       $arr[$i] = $i;
    }

    return $self;
}

sub num_get
{
    my $self = shift;
    my ($type) = @_;

    eval {
        no strict ;
        return $#type;
    }
}



--- Client code

use A;

my $try = A -> new ("something");

print $try -> num_get ('arr');


---
The client code always prints -1.

When I try debugging the code, arr looks good in the for loop in the
'new' function, but after coming out of the for loop it shows nothing.

Could someone thrown light on this ?

thanks a lot,
tarak

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Reply via email to