C struct equivalent

M

Martin Johansen

Hello

I need to use structure like:

struct{
int x;
array *a;
int z;
}s;

Can I access some structure in perl using e.g. s.a or similar

Thanks.
 
X

xhoster

Martin Johansen said:
Hello

I need to use structure like:

struct{
int x;
array *a;
int z;
}s;

Can I access some structure in perl using e.g. s.a or similar

perldoc -q struct

Xho
 
T

Tad McClellan

Martin Johansen said:
Subject: C struct equivalent


perldoc -q struct

How can I make the Perl equivalent of a C structure/C++ class/hash or
array of hashes or arrays?

How do I declare/create a structure?


You are expected to check the Perl FAQ *before* posting to
the Perl newsgroup.
 
C

Chris Mattern

Martin said:
Hello

I need to use structure like:

struct{
int x;
array *a;
int z;
}s;

Can I access some structure in perl using e.g. s.a or similar

Thanks.

Normal way to do this is with a hash:

my %s = (
x => 0,
a => [],
z => 0
);

--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top