Christopher J. Bottaro wrote:
is there a way to iterate over the fields of a Class::Struct (in the order
they were declared)?

No. You could store the data used to generate the struct, and then use it later.


my @struct_data = [
  key1 => 'type',
  key2 => 'type',
];

struct Name => [EMAIL PROTECTED];

then iterate of @struct_data...


yeah i know its a long shot, but perl sometimes does things for me that i never would have believed...much less knew to expect...;)

also, i know you can do this with hashes (although in "random" order, unless
you sort the keys), but hashes are too error prone for my liking.  i.e.
$my_hash{TYPO} = $blah; does not result in an error...=(

If you're using version 5.8 or later you can use restricted hashes. See `perldoc Hash::Util`


Randy.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to