For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2004 > RE : iterate over the fields of a struct?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE : iterate over the fields of a struct?
Jose Nyimi

2004-08-07, 8:55 am



> -----Message d'origine-----
> De=A0: Randy W. Sims [mailto:randys@thepierianspring.org]
> Envoy=E9=A0: samedi 7 ao=FBt 2004 02:50
> =C0=A0: cjbottaro@alumni.cs.utexas.edu
> Cc=A0: beginners@perl.org
> Objet=A0: Re: iterate over the fields of a struct?
>=20
> Christopher J. Bottaro wrote:
> order
>=20
> No. You could store the data used to generate the struct, and then use
> it later.
>=20
> my @struct_data =3D [
> key1 =3D> 'type',
> key2 =3D> 'type',
> ];
>=20
> struct Name =3D> \@struct_data;
>=20
> then iterate of @struct_data...
>=20


did you meant:

my $struct_data =3D [ #array_ref
key1 =3D> 'type',
key2 =3D> 'type',
];

struct Name =3D> $struct_data;
then iterate of @$struct_data ...

?

array =3D array_ref is confusing to me ...
could you explain please ?

that[color=darkred]
> i
order,[color=darkred]
> unless
i.e.[color=darkred]
>=20
> If you're using version 5.8 or later you can use restricted hashes.

See
> `perldoc Hash::Util`
>=20


helpfull module !
Hash vivification is a nightmare, really ...

Jos=E9.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com