use Class::Struct;
struct STRUCT1 => {
a => '$',#a is a scalar
b => '$',
c => '$',
};
$s = STRUCT1->new();
$s->a(1);
$s->b(2);
$s->c(3);
#
printf "\na = %d, b = %d c = %d\n\n", $s->a, $s->b, $s->c;
__
William Ampeh (x3939)
Federal Reserve Board
--
> How do I simulate an array of structures in perl?
my @array = \(%struct1, %struct2, %struct3);
or something like that anyway. You learning or trying
to convert C code into Perl? Compared to C, you don't
use an array as often in Perl - but hashes.
E.g.
my %records = (
'id0001' => {
How do I simulate an array of structures in perl?
eg.
struct {
int a;
int b;
int c
} STRUCT1;
int STRUCT1 s[5];
s[1].a =1;
s[1].b =2;
s[1].c =3;
How would I write this in perl?
Thanks.
The information contained in this message may
> Hmm... another question.. will this kinda of stuff be easier in Perl 6?
Perhaps, need to browse the RFC list at:
http://dev.perl.org/rfc
to find out. Anything can change!
Jonathan Paton
__
Do You Yahoo!?
Everything you'll ever need on one we
> How would you define c type structures in perl?
perldoc Class::Struct
if installed... else:
> struct {
> int a;
> int b;
> int c
> } STRUCT1;
>
> int STRUCT1 s;
my %struct = (
a => undef,
b => undef,
c => undef
);
> s.a =1;
> s.b =2;
> s.c =3;
$struct{a} = 1;
$struct{b} = 2;
$s
Roy Peters wrote:
>How would you define c type structures in perl?
>
>eg.
>
>struct {
>int a;
>int b;
>int c
>} STRUCT1;
>
>int STRUCT1 s;
>
>s.a =1;
>s.b =2;
>s.c =3;
>
>How would I write this in perl?
>
>Thanks.
>
$s{'a'}=1;
$s{'b'}=2;
$s{'c'}=3;
Walter
--
To unsubscribe, e-mail: [EMA
Hmm... another question.. will this kinda of stuff be easier in Perl 6?
> -Original Message-
> From: Roy Peters [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 10, 2002 9:38 AM
> To: [EMAIL PROTECTED]
> Subject: simulating c structures in perl
>
>
> How would you define c type stru