Pointers in Perl?

Status
Not open for further replies.

Magus`

Ars Legatus Legionis
30,136
Subscriptor++
Are there pointers in Perl? My attempts and finding info on this have turned up nothing...

I have a CS assignment I need to do, but I would like both pointers and regex :D

Otherwise I have to write it in C++ and code the pattern matching myself (ugh)

Alternatively, is there a struct like thing in Perl?

Basically, I want to be able to make something like this:

code:<HR>
Code:
struct Node {
    char oper;
    Node *L, *R;
}
or
code:<HR>
Code:
struct Node {
    char oper;
    Node L, R;
}

If at all possible :D

Thanks in advance,
Magus`
 

_klamath_

Ars Scholae Palatinae
770
Perl has references, which are similar (but not identical to) pointers in C. They will allow you to do what you want.

As for the assignment, most complex data structures are implemented in Perl via hashes and/or arrays. I would suggest you refer to "Mastering Algorithms with Perl", which covers this in detail. In short -- yes, you can easily do what you're looking for in Perl.
 
Status
Not open for further replies.