How to get an array to work with oops concepts in Perl

Posted by superstar on Stack Overflow See other posts from Stack Overflow or by superstar
Published on 2010-04-01T15:18:17Z Indexed on 2010/04/01 15:23 UTC
Read the original article Hit count: 531

Filed under:
|
|

Hello guys, I need some help regarding the arrays in Perl

This is the constructor i have.

sub new {
    my $class = shift;
    my @includeobjects = ();
    my @excludeobjects = ();

    my $Packet = {
        _PacketName => shift,
        _Platform  => shift,
        _Version => shift,
    @_IncludePath => @includeobjects,
    };
  bless $Packet, $class;
    return $Packet;
}

sub SetPacketName {
    my ( $Packet, $PacketName ) = @_;
    $Packet->{_PacketName} = $PacketName if defined($PacketName);
    return $Packet->{_PacketName};
}

sub SetIncludePath {
    my ( $Packet, @IncludePath ) = @_;
    $Packet->{@_IncludePath} = @IncludePath;
    return $Packet->{@_IncludePath};
}

sub GetPacketName {
    my( $Packet ) = @_;
    return $Packet->{_PacketName};
}

sub GetIncludePath {
    my( $Packet ) = @_;
    return $Packet->{@_IncludePath};
}

The get and set methods work fine for PacketName. But since IncludePath is an array, I could not get it work. The declaration is what i am not able to get right Any suggestions please...

© Stack Overflow or respective owner

Related posts about perl

Related posts about array