I'm looking to build a Node class in Perl (using the keyword 'package'), but I'm not sure how to create a pointer to class variable like in C++.
In C++, you have:
class Node
{
public:
int key;
Node* left;
Node* right;
Node(int _key)
{
key = _key;
left = NULL;
right = NULL;
}
};
In Perl:
package Node;
sub Node
{
my $class = shift;
my $key;
Node* left; # Of course, this will not work
Node* right;
}
Is there any way I could make a pointer to class variable in Perl? Or if it's not possible, any suggestions on Perl modules that could do what I want to do?